| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 thread for scheduling. |
| 6 // for scheduling. Assumes the current message loop is already | 6 // Assumes the current thread is already running tasks. |
| 7 // running. | |
| 8 | 7 |
| 9 #ifndef COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ | 8 #ifndef COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ |
| 10 #define COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ | 9 #define COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ |
| 11 | 10 |
| 12 #include <memory> | 11 #include <memory> |
| 13 #include <set> | 12 #include <set> |
| 14 #include <string> | 13 #include <string> |
| 15 #include <vector> | 14 #include <vector> |
| 16 | 15 |
| 17 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "components/invalidation/impl/state_writer.h" | 22 #include "components/invalidation/impl/state_writer.h" |
| 23 #include "components/invalidation/public/invalidation_export.h" | 23 #include "components/invalidation/public/invalidation_export.h" |
| 24 #include "components/invalidation/public/invalidator_state.h" | 24 #include "components/invalidation/public/invalidator_state.h" |
| 25 #include "google/cacheinvalidation/include/system-resources.h" | 25 #include "google/cacheinvalidation/include/system-resources.h" |
| 26 #include "jingle/notifier/base/notifier_options.h" | 26 #include "jingle/notifier/base/notifier_options.h" |
| 27 | 27 |
| 28 namespace syncer { | 28 namespace syncer { |
| 29 | 29 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 void SetSystemResources(invalidation::SystemResources* resources) override; | 66 void SetSystemResources(invalidation::SystemResources* resources) override; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 // Runs the task, deletes it, and removes it from |posted_tasks_|. | 69 // Runs the task, deletes it, and removes it from |posted_tasks_|. |
| 70 void RunPostedTask(invalidation::Closure* task); | 70 void RunPostedTask(invalidation::Closure* task); |
| 71 | 71 |
| 72 // Holds all posted tasks that have not yet been run. | 72 // Holds all posted tasks that have not yet been run. |
| 73 std::set<invalidation::Closure*> posted_tasks_; | 73 std::set<invalidation::Closure*> posted_tasks_; |
| 74 | 74 |
| 75 const base::MessageLoop* created_on_loop_; | 75 scoped_refptr<base::SingleThreadTaskRunner> const created_on_task_runner_; |
| 76 bool is_started_; | 76 bool is_started_; |
| 77 bool is_stopped_; | 77 bool is_stopped_; |
| 78 | 78 |
| 79 base::WeakPtrFactory<SyncInvalidationScheduler> weak_factory_; | 79 base::WeakPtrFactory<SyncInvalidationScheduler> weak_factory_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // SyncNetworkChannel implements common tasks needed to interact with | 82 // SyncNetworkChannel implements common tasks needed to interact with |
| 83 // invalidation library: | 83 // invalidation library: |
| 84 // - registering message and network status callbacks | 84 // - registering message and network status callbacks |
| 85 // - notifying observers about network channel state change | 85 // - notifying observers about network channel state change |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 std::unique_ptr<SyncInvalidationScheduler> internal_scheduler_; | 240 std::unique_ptr<SyncInvalidationScheduler> internal_scheduler_; |
| 241 std::unique_ptr<SyncInvalidationScheduler> listener_scheduler_; | 241 std::unique_ptr<SyncInvalidationScheduler> listener_scheduler_; |
| 242 std::unique_ptr<SyncStorage> storage_; | 242 std::unique_ptr<SyncStorage> storage_; |
| 243 // sync_network_channel_ is owned by SyncInvalidationListener. | 243 // sync_network_channel_ is owned by SyncInvalidationListener. |
| 244 SyncNetworkChannel* sync_network_channel_; | 244 SyncNetworkChannel* sync_network_channel_; |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 } // namespace syncer | 247 } // namespace syncer |
| 248 | 248 |
| 249 #endif // COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ | 249 #endif // COMPONENTS_INVALIDATION_IMPL_SYNC_SYSTEM_RESOURCES_H_ |
| OLD | NEW |