OLD | NEW |
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.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 136 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
137 RemoveKeysForExtension( | 137 RemoveKeysForExtension( |
138 content::Details<const Extension>(details)->id()); | 138 content::Details<const Extension>(details)->id()); |
139 break; | 139 break; |
140 case chrome::NOTIFICATION_SESSION_RESTORE_DONE: | 140 case chrome::NOTIFICATION_SESSION_RESTORE_DONE: |
141 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: | 141 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: |
142 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 142 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
143 content::NotificationService::AllSources()); | 143 content::NotificationService::AllSources()); |
144 registrar_.Remove(this, chrome::NOTIFICATION_SESSION_RESTORE_DONE, | 144 registrar_.Remove(this, chrome::NOTIFICATION_SESSION_RESTORE_DONE, |
145 content::NotificationService::AllSources()); | 145 content::NotificationService::AllSources()); |
146 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 146 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
147 base::Bind(&StateStore::Init, AsWeakPtr()), | 147 base::Bind(&StateStore::Init, AsWeakPtr()), |
148 base::TimeDelta::FromSeconds(kInitDelaySeconds)); | 148 base::TimeDelta::FromSeconds(kInitDelaySeconds)); |
149 break; | 149 break; |
150 default: | 150 default: |
151 NOTREACHED(); | 151 NOTREACHED(); |
152 return; | 152 return; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void StateStore::Init() { | 156 void StateStore::Init() { |
157 if (!db_path_.empty()) | 157 if (!db_path_.empty()) |
158 store_.Init(db_path_); | 158 store_.Init(db_path_); |
159 task_queue_->SetReady(); | 159 task_queue_->SetReady(); |
160 } | 160 } |
161 | 161 |
162 void StateStore::RemoveKeysForExtension(const std::string& extension_id) { | 162 void StateStore::RemoveKeysForExtension(const std::string& extension_id) { |
163 for (std::set<std::string>::iterator key = registered_keys_.begin(); | 163 for (std::set<std::string>::iterator key = registered_keys_.begin(); |
164 key != registered_keys_.end(); ++key) { | 164 key != registered_keys_.end(); ++key) { |
165 task_queue_->InvokeWhenReady( | 165 task_queue_->InvokeWhenReady( |
166 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), | 166 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), |
167 GetFullKey(extension_id, *key))); | 167 GetFullKey(extension_id, *key))); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 } // namespace extensions | 171 } // namespace extensions |
OLD | NEW |