Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: chrome/browser/chromeos/drive/change_list_loader.h

Issue 132903008: drive: Implement lock mechanism to ChangeListLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/change_list_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/change_list_loader.h
diff --git a/chrome/browser/chromeos/drive/change_list_loader.h b/chrome/browser/chromeos/drive/change_list_loader.h
index 620caca9504b0480ce6b7cb272be40887ee003b7..df8ac2561e1e9ca8ff711bda9e21e45a9f94b29a 100644
--- a/chrome/browser/chromeos/drive/change_list_loader.h
+++ b/chrome/browser/chromeos/drive/change_list_loader.h
@@ -22,6 +22,7 @@
class GURL;
namespace base {
+class ScopedClosureRunner;
class SequencedTaskRunner;
class Time;
} // namespace base
@@ -103,6 +104,12 @@ class ChangeListLoader {
// calls |UpdateAboutResource| passing |callback|.
void GetAboutResource(const google_apis::AboutResourceCallback& callback);
+ // Increments the lock count and returns an object which decrements the count
+ // on its destruction.
+ // While the lock count is positive, ChangeListLoader does not add any entries
+ // to the local metadata.
+ scoped_ptr<base::ScopedClosureRunner> GetLock();
+
private:
// Part of LoadDirectoryIfNeeded().
void LoadDirectoryIfNeededAfterGetEntry(const base::FilePath& directory_path,
@@ -191,6 +198,14 @@ class ChangeListLoader {
const base::FilePath* directory_path,
FileError error);
+ // ================= Implementation for lock mechanism ====================
+ // Runs the closure if the lock count is 0, otherwise it will be pending.
+ // All tasks which may add entries should be run via this method.
+ void ApplyChange(const base::Closure& closure);
+
+ // Decrements the lock count.
+ void Unlock();
+
// ================= Implementation for other stuff =================
// Gets the about resource from the server, and caches it if successful. This
@@ -217,6 +232,9 @@ class ChangeListLoader {
LoadCallbackMap pending_load_callback_;
FileOperationCallback pending_update_check_callback_;
+ int lock_count_;
+ std::vector<base::Closure> pending_apply_closures_;
+
// Running feed fetcher.
scoped_ptr<FeedFetcher> change_feed_fetcher_;
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/change_list_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698