Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/browser/background_sync/background_sync.pb.h" | |
| 14 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 15 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
| 15 #include "content/browser/service_worker/service_worker_context_observer.h" | 16 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 16 #include "content/browser/service_worker/service_worker_storage.h" | 17 #include "content/browser/service_worker/service_worker_storage.h" |
| 17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 18 #include "content/common/service_worker/service_worker_status_code.h" | 19 #include "content/common/service_worker/service_worker_status_code.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 class ServiceWorkerContextWrapper; | 24 class ServiceWorkerContextWrapper; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 44 ERROR_TYPE_OK = 0, | 45 ERROR_TYPE_OK = 0, |
| 45 ERROR_TYPE_STORAGE, | 46 ERROR_TYPE_STORAGE, |
| 46 ERROR_TYPE_NOT_FOUND | 47 ERROR_TYPE_NOT_FOUND |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 // TODO(jkarlin): Remove this and use the struct from IPC messages once it | 50 // TODO(jkarlin): Remove this and use the struct from IPC messages once it |
| 50 // lands. | 51 // lands. |
| 51 struct CONTENT_EXPORT BackgroundSyncRegistration { | 52 struct CONTENT_EXPORT BackgroundSyncRegistration { |
| 52 using RegistrationId = int64; | 53 using RegistrationId = int64; |
| 53 static const RegistrationId kInvalidRegistrationId; | 54 static const RegistrationId kInvalidRegistrationId; |
| 54 | |
| 55 BackgroundSyncRegistration() | 55 BackgroundSyncRegistration() |
| 56 : BackgroundSyncRegistration(kInvalidRegistrationId, "") {} | 56 : id(kInvalidRegistrationId), |
|
johnme
2015/04/07 17:05:12
Nit: easier to read if you remove this constructor
jkarlin
2015/04/07 17:55:06
Done.
| |
| 57 explicit BackgroundSyncRegistration(const std::string& name) | 57 fire_once(true), |
| 58 : BackgroundSyncRegistration(kInvalidRegistrationId, name) {} | 58 min_period(0), |
| 59 BackgroundSyncRegistration(int64 id, const std::string& name) | 59 network_state(NETWORK_STATE_ONLINE), |
| 60 : id(id), min_period(0), name(name) {} | 60 power_state(POWER_STATE_AVOID_DRAINING) {} |
| 61 | 61 |
| 62 bool Equals(const BackgroundSyncRegistration& other) { | 62 bool Equals(const BackgroundSyncRegistration& other) { |
| 63 return this->name == other.name && this->min_period == other.min_period; | 63 return this->name == other.name && this->fire_once == other.fire_once && |
| 64 this->min_period == other.min_period && | |
| 65 network_state == other.network_state && | |
| 66 power_state == other.power_state; | |
| 64 } | 67 } |
| 65 | 68 |
| 66 RegistrationId id; | 69 RegistrationId id; |
| 70 std::string name; | |
| 71 bool fire_once; | |
| 67 int64 min_period; | 72 int64 min_period; |
| 68 std::string name; | 73 SyncNetworkState network_state; |
| 74 SyncPowerState power_state; | |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 struct CONTENT_EXPORT BackgroundSyncRegistrations { | 77 struct CONTENT_EXPORT BackgroundSyncRegistrations { |
| 72 using NameToRegistrationMap = | 78 using NameToRegistrationMap = |
| 73 std::map<std::string, BackgroundSyncRegistration>; | 79 std::map<std::string, BackgroundSyncRegistration>; |
| 74 static const BackgroundSyncRegistration::RegistrationId kInitialId; | 80 static const BackgroundSyncRegistration::RegistrationId kInitialId; |
| 75 | 81 |
| 76 BackgroundSyncRegistrations(); | 82 BackgroundSyncRegistrations(); |
| 77 explicit BackgroundSyncRegistrations( | 83 explicit BackgroundSyncRegistrations( |
| 78 BackgroundSyncRegistration::RegistrationId next_id); | 84 BackgroundSyncRegistration::RegistrationId next_id); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 bool disabled_; | 251 bool disabled_; |
| 246 | 252 |
| 247 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 253 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
| 248 | 254 |
| 249 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 255 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
| 250 }; | 256 }; |
| 251 | 257 |
| 252 } // namespace content | 258 } // namespace content |
| 253 | 259 |
| 254 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 260 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |