mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1246209
- Add getProfileCreationDate, implement from filestystem, & add stencil code. r=mfinkle
Retrieving the profile creation date from the filesystem is not strictly necessary to upload this data and returns -1 until it is implemented. If the decision is r+'d here, it will be implemented in bug 1246816.
This commit is contained in:
parent
85c3cb6030
commit
59539bf626
@ -51,6 +51,9 @@ public final class GeckoProfile {
|
||||
// In the client ID file, the attribute title in the JSON object containing the client ID value.
|
||||
private static final String CLIENT_ID_JSON_ATTR = "clientID";
|
||||
|
||||
private static final String TIMES_PATH = "times.json";
|
||||
private static final String PROFILE_CREATION_DATE_JSON_ATTR = "created";
|
||||
|
||||
// Only tests should need to do this.
|
||||
// We can default this to AppConstants.RELEASE_BUILD once we fix Bug 1069687.
|
||||
private static volatile boolean sAcceptDirectoryChanges = true;
|
||||
@ -622,6 +625,40 @@ public final class GeckoProfile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the profile creation date in the format returned by {@link System#currentTimeMillis()} or -1 if the value
|
||||
* was not found.
|
||||
*/
|
||||
@WorkerThread
|
||||
public long getProfileCreationDate() {
|
||||
try {
|
||||
return getProfileCreationDateFromTimesFile();
|
||||
} catch (final IOException e) {
|
||||
return getAndPersistProfileCreationDateFromFilesystem();
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private long getProfileCreationDateFromTimesFile() throws IOException {
|
||||
final JSONObject obj = readJSONObjectFromFile(TIMES_PATH);
|
||||
try {
|
||||
return obj.getLong(PROFILE_CREATION_DATE_JSON_ATTR);
|
||||
} catch (final JSONException e) {
|
||||
// Don't log to avoid leaking data in JSONObject.
|
||||
throw new IOException("Profile creation does not exist in JSONObject");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO (bug 1246816): Implement ProfileAge.jsm - getOldestProfileTimestamp. Persist results to times.json.
|
||||
* Update comment in getProfileCreationDate too.
|
||||
* @return -1 until implemented.
|
||||
*/
|
||||
@WorkerThread
|
||||
private long getAndPersistProfileCreationDateFromFilesystem() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the session file to the backup session file.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user