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

Unified Diff: chrome/browser/sync/notifier/chrome_system_resources.h

Issue 2979003: Reworked ChromeSystemResources to handle callbacks properly. (Closed)
Patch Set: Fixed compile error Created 10 years, 5 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/sync/notifier/chrome_system_resources.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/notifier/chrome_system_resources.h
diff --git a/chrome/browser/sync/notifier/chrome_system_resources.h b/chrome/browser/sync/notifier/chrome_system_resources.h
index a8a98df9e387fdd664c4bab6d8e40f33d4a49fc5..14d69d9ea737663ef0a73cb13cb732ec361e3b2c 100644
--- a/chrome/browser/sync/notifier/chrome_system_resources.h
+++ b/chrome/browser/sync/notifier/chrome_system_resources.h
@@ -9,28 +9,27 @@
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_
+#include <set>
+
+#include "base/non_thread_safe.h"
+#include "base/scoped_ptr.h"
+#include "base/task.h"
#include "google/cacheinvalidation/invalidation-client.h"
namespace sync_notifier {
-// TODO(akalin): Add a NonThreadSafe member to this class and use it.
-
class ChromeSystemResources : public invalidation::SystemResources {
public:
ChromeSystemResources();
~ChromeSystemResources();
+ // invalidation::SystemResources implementation.
+
virtual invalidation::Time current_time();
virtual void StartScheduler();
- // We assume that the current message loop is stopped shortly after
- // this is called, i.e. that any in-flight delayed tasks won't get
- // run.
- //
- // TODO(akalin): Make sure that the above actually holds. Use a
- // ScopedRunnableMethodFactory for better safety.
virtual void StopScheduler();
virtual void ScheduleWithDelay(invalidation::TimeDelta delay,
@@ -42,7 +41,19 @@ class ChromeSystemResources : public invalidation::SystemResources {
const char* format, ...);
private:
- bool scheduler_active_;
+ NonThreadSafe non_thread_safe_;
+ scoped_ptr<ScopedRunnableMethodFactory<ChromeSystemResources> >
+ scoped_runnable_method_factory_;
+ // Holds all posted tasks that have not yet been run.
+ std::set<invalidation::Closure*> posted_tasks_;
+
+ // If the scheduler has been started, inserts |task| into
+ // |posted_tasks_| and returns a Task* to post. Otherwise,
+ // immediately deletes |task| and returns NULL.
+ Task* MakeTaskToPost(invalidation::Closure* task);
+
+ // Runs the task, deletes it, and removes it from |posted_tasks_|.
+ void RunPostedTask(invalidation::Closure* task);
};
} // namespace sync_notifier
« no previous file with comments | « no previous file | chrome/browser/sync/notifier/chrome_system_resources.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698