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

Side by Side Diff: chrome/browser/extensions/state_store.cc

Issue 186013003: Persist browseraction properties across restarts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 9 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
« no previous file with comments | « chrome/browser/extensions/state_store.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/state_store.h" 5 #include "chrome/browser/extensions/state_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 21 matching lines...) Expand all
32 DelayedTaskQueue() : ready_(false) {} 32 DelayedTaskQueue() : ready_(false) {}
33 ~DelayedTaskQueue() {} 33 ~DelayedTaskQueue() {}
34 34
35 // Queues up a task for invoking once we're ready. Invokes immediately if 35 // Queues up a task for invoking once we're ready. Invokes immediately if
36 // we're already ready. 36 // we're already ready.
37 void InvokeWhenReady(base::Closure task); 37 void InvokeWhenReady(base::Closure task);
38 38
39 // Marks us ready, and invokes all pending tasks. 39 // Marks us ready, and invokes all pending tasks.
40 void SetReady(); 40 void SetReady();
41 41
42 // Return whether or not the DelayedTaskQueue is |ready_|.
43 bool ready() const { return ready_; }
44
42 private: 45 private:
43 bool ready_; 46 bool ready_;
44 std::vector<base::Closure> pending_tasks_; 47 std::vector<base::Closure> pending_tasks_;
45 }; 48 };
46 49
47 void StateStore::DelayedTaskQueue::InvokeWhenReady(base::Closure task) { 50 void StateStore::DelayedTaskQueue::InvokeWhenReady(base::Closure task) {
48 if (ready_) { 51 if (ready_) {
49 task.Run(); 52 task.Run();
50 } else { 53 } else {
51 pending_tasks_.push_back(task); 54 pending_tasks_.push_back(task);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 GetFullKey(extension_id, key), base::Passed(&value))); 120 GetFullKey(extension_id, key), base::Passed(&value)));
118 } 121 }
119 122
120 void StateStore::RemoveExtensionValue(const std::string& extension_id, 123 void StateStore::RemoveExtensionValue(const std::string& extension_id,
121 const std::string& key) { 124 const std::string& key) {
122 task_queue_->InvokeWhenReady( 125 task_queue_->InvokeWhenReady(
123 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), 126 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_),
124 GetFullKey(extension_id, key))); 127 GetFullKey(extension_id, key)));
125 } 128 }
126 129
130 bool StateStore::IsInitialized() const { return task_queue_->ready(); }
131
127 void StateStore::Observe(int type, 132 void StateStore::Observe(int type,
128 const content::NotificationSource& source, 133 const content::NotificationSource& source,
129 const content::NotificationDetails& details) { 134 const content::NotificationDetails& details) {
130 switch (type) { 135 switch (type) {
131 case chrome::NOTIFICATION_EXTENSION_INSTALLED: 136 case chrome::NOTIFICATION_EXTENSION_INSTALLED:
132 RemoveKeysForExtension( 137 RemoveKeysForExtension(
133 content::Details<const InstalledExtensionInfo>(details)->extension-> 138 content::Details<const InstalledExtensionInfo>(details)->extension->
134 id()); 139 id());
135 break; 140 break;
136 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: 141 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED:
(...skipping 25 matching lines...) Expand all
162 void StateStore::RemoveKeysForExtension(const std::string& extension_id) { 167 void StateStore::RemoveKeysForExtension(const std::string& extension_id) {
163 for (std::set<std::string>::iterator key = registered_keys_.begin(); 168 for (std::set<std::string>::iterator key = registered_keys_.begin();
164 key != registered_keys_.end(); ++key) { 169 key != registered_keys_.end(); ++key) {
165 task_queue_->InvokeWhenReady( 170 task_queue_->InvokeWhenReady(
166 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), 171 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_),
167 GetFullKey(extension_id, *key))); 172 GetFullKey(extension_id, *key)));
168 } 173 }
169 } 174 }
170 175
171 } // namespace extensions 176 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/state_store.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698