| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Simple system resources class that uses the current message loop | 5 // Simple system resources class that uses the current message loop |
| 6 // for scheduling. Assumes the current message loop is already | 6 // for scheduling. Assumes the current message loop is already |
| 7 // running. | 7 // running. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ | 9 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ |
| 10 #define CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ | 10 #define CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ |
| 11 #pragma once | 11 #pragma once |
| 12 | 12 |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "base/message_loop.h" |
| 16 #include "base/non_thread_safe.h" | 17 #include "base/non_thread_safe.h" |
| 17 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
| 18 #include "base/task.h" | 19 #include "base/task.h" |
| 19 #include "chrome/browser/sync/notifier/state_writer.h" | 20 #include "chrome/browser/sync/notifier/state_writer.h" |
| 20 #include "google/cacheinvalidation/invalidation-client.h" | 21 #include "google/cacheinvalidation/invalidation-client.h" |
| 21 | 22 |
| 22 namespace sync_notifier { | 23 namespace sync_notifier { |
| 23 | 24 |
| 24 class ChromeSystemResources : public invalidation::SystemResources { | 25 class ChromeSystemResources : public invalidation::SystemResources { |
| 25 public: | 26 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 invalidation::StorageCallback* callback); | 52 invalidation::StorageCallback* callback); |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 NonThreadSafe non_thread_safe_; | 55 NonThreadSafe non_thread_safe_; |
| 55 scoped_ptr<ScopedRunnableMethodFactory<ChromeSystemResources> > | 56 scoped_ptr<ScopedRunnableMethodFactory<ChromeSystemResources> > |
| 56 scoped_runnable_method_factory_; | 57 scoped_runnable_method_factory_; |
| 57 // Holds all posted tasks that have not yet been run. | 58 // Holds all posted tasks that have not yet been run. |
| 58 std::set<invalidation::Closure*> posted_tasks_; | 59 std::set<invalidation::Closure*> posted_tasks_; |
| 59 StateWriter* state_writer_; | 60 StateWriter* state_writer_; |
| 60 | 61 |
| 62 // TODO(tim): Trying to debug bug crbug.com/64652. |
| 63 const MessageLoop* created_on_loop_; |
| 64 |
| 61 // If the scheduler has been started, inserts |task| into | 65 // If the scheduler has been started, inserts |task| into |
| 62 // |posted_tasks_| and returns a Task* to post. Otherwise, | 66 // |posted_tasks_| and returns a Task* to post. Otherwise, |
| 63 // immediately deletes |task| and returns NULL. | 67 // immediately deletes |task| and returns NULL. |
| 64 Task* MakeTaskToPost(invalidation::Closure* task); | 68 Task* MakeTaskToPost(invalidation::Closure* task); |
| 65 | 69 |
| 66 // Runs the task, deletes it, and removes it from |posted_tasks_|. | 70 // Runs the task, deletes it, and removes it from |posted_tasks_|. |
| 67 void RunPostedTask(invalidation::Closure* task); | 71 void RunPostedTask(invalidation::Closure* task); |
| 68 | 72 |
| 69 // Runs the given storage callback with "true" and deletes it. | 73 // Runs the given storage callback with "true" and deletes it. |
| 70 void RunAndDeleteStorageCallback( | 74 void RunAndDeleteStorageCallback( |
| 71 invalidation::StorageCallback* callback); | 75 invalidation::StorageCallback* callback); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace sync_notifier | 78 } // namespace sync_notifier |
| 75 | 79 |
| 76 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ | 80 #endif // CHROME_BROWSER_SYNC_NOTIFIER_CHROME_SYSTEM_RESOURCES_H_ |
| OLD | NEW |