| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 task_queue_->InvokeWhenReady( | 122 task_queue_->InvokeWhenReady( |
| 123 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), | 123 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), |
| 124 GetFullKey(extension_id, key))); | 124 GetFullKey(extension_id, key))); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void StateStore::Observe(int type, | 127 void StateStore::Observe(int type, |
| 128 const content::NotificationSource& source, | 128 const content::NotificationSource& source, |
| 129 const content::NotificationDetails& details) { | 129 const content::NotificationDetails& details) { |
| 130 switch (type) { | 130 switch (type) { |
| 131 case chrome::NOTIFICATION_EXTENSION_INSTALLED: | 131 case chrome::NOTIFICATION_EXTENSION_INSTALLED: |
| 132 RemoveKeysForExtension( |
| 133 content::Details<const InstalledExtensionInfo>(details)->extension-> |
| 134 id()); |
| 135 break; |
| 132 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 136 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
| 133 RemoveKeysForExtension( | 137 RemoveKeysForExtension( |
| 134 content::Details<const Extension>(details).ptr()->id()); | 138 content::Details<const Extension>(details)->id()); |
| 135 break; | 139 break; |
| 136 case chrome::NOTIFICATION_SESSION_RESTORE_DONE: | 140 case chrome::NOTIFICATION_SESSION_RESTORE_DONE: |
| 137 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: | 141 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: |
| 138 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 142 registrar_.Remove(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 139 content::NotificationService::AllSources()); | 143 content::NotificationService::AllSources()); |
| 140 registrar_.Remove(this, chrome::NOTIFICATION_SESSION_RESTORE_DONE, | 144 registrar_.Remove(this, chrome::NOTIFICATION_SESSION_RESTORE_DONE, |
| 141 content::NotificationService::AllSources()); | 145 content::NotificationService::AllSources()); |
| 142 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 146 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 143 base::Bind(&StateStore::Init, AsWeakPtr()), | 147 base::Bind(&StateStore::Init, AsWeakPtr()), |
| 144 base::TimeDelta::FromSeconds(kInitDelaySeconds)); | 148 base::TimeDelta::FromSeconds(kInitDelaySeconds)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 158 void StateStore::RemoveKeysForExtension(const std::string& extension_id) { | 162 void StateStore::RemoveKeysForExtension(const std::string& extension_id) { |
| 159 for (std::set<std::string>::iterator key = registered_keys_.begin(); | 163 for (std::set<std::string>::iterator key = registered_keys_.begin(); |
| 160 key != registered_keys_.end(); ++key) { | 164 key != registered_keys_.end(); ++key) { |
| 161 task_queue_->InvokeWhenReady( | 165 task_queue_->InvokeWhenReady( |
| 162 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), | 166 base::Bind(&ValueStoreFrontend::Remove, base::Unretained(&store_), |
| 163 GetFullKey(extension_id, *key))); | 167 GetFullKey(extension_id, *key))); |
| 164 } | 168 } |
| 165 } | 169 } |
| 166 | 170 |
| 167 } // namespace extensions | 171 } // namespace extensions |
| OLD | NEW |