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