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

Side by Side Diff: content/browser/background_sync/background_sync_manager.h

Issue 1068863002: [BackgroundSync] Add new registration options from the spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS1 Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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
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, "") {}
57 explicit BackgroundSyncRegistration(const std::string& name)
58 : BackgroundSyncRegistration(kInvalidRegistrationId, name) {}
59 BackgroundSyncRegistration(int64 id, const std::string& name)
60 : id(id), min_period(0), name(name) {}
61 56
62 bool Equals(const BackgroundSyncRegistration& other) { 57 bool Equals(const BackgroundSyncRegistration& other) {
63 return this->name == other.name && this->min_period == other.min_period; 58 return this->name == other.name && this->fire_once == other.fire_once &&
59 this->min_period == other.min_period &&
60 network_state == other.network_state &&
61 power_state == other.power_state;
64 } 62 }
65 63
66 RegistrationId id; 64 RegistrationId id = kInvalidRegistrationId;
67 int64 min_period;
68 std::string name; 65 std::string name;
66 bool fire_once = true;
67 int64 min_period = 0;
68 SyncNetworkState network_state = NETWORK_STATE_ONLINE;
69 SyncPowerState power_state = POWER_STATE_AVOID_DRAINING;
69 }; 70 };
70 71
71 struct CONTENT_EXPORT BackgroundSyncRegistrations { 72 struct CONTENT_EXPORT BackgroundSyncRegistrations {
72 using NameToRegistrationMap = 73 using NameToRegistrationMap =
73 std::map<std::string, BackgroundSyncRegistration>; 74 std::map<std::string, BackgroundSyncRegistration>;
74 static const BackgroundSyncRegistration::RegistrationId kInitialId; 75 static const BackgroundSyncRegistration::RegistrationId kInitialId;
75 76
76 BackgroundSyncRegistrations(); 77 BackgroundSyncRegistrations();
77 explicit BackgroundSyncRegistrations( 78 explicit BackgroundSyncRegistrations(
78 BackgroundSyncRegistration::RegistrationId next_id); 79 BackgroundSyncRegistration::RegistrationId next_id);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 bool disabled_; 246 bool disabled_;
246 247
247 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; 248 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_;
248 249
249 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); 250 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager);
250 }; 251 };
251 252
252 } // namespace content 253 } // namespace content
253 254
254 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ 255 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/background_sync/background_sync.proto ('k') | content/browser/background_sync/background_sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698