OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/glue/extension_change_processor.h" | 5 #include "chrome/browser/sync/glue/extension_change_processor.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
12 #include "chrome/browser/browser_thread.h" | 12 #include "chrome/browser/browser_thread.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/sync/glue/extension_sync.h" | 15 #include "chrome/browser/sync/glue/extension_sync.h" |
16 #include "chrome/browser/sync/glue/extension_util.h" | 16 #include "chrome/browser/sync/glue/extension_util.h" |
17 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" | 17 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/notification_details.h" | 19 #include "chrome/common/notification_details.h" |
20 #include "chrome/common/notification_source.h" | 20 #include "chrome/common/notification_source.h" |
21 | 21 |
22 namespace browser_sync { | 22 namespace browser_sync { |
23 | 23 |
24 ExtensionChangeProcessor::ExtensionChangeProcessor( | 24 ExtensionChangeProcessor::ExtensionChangeProcessor( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 void ExtensionChangeProcessor::ApplyChangesFromSyncModel( | 91 void ExtensionChangeProcessor::ApplyChangesFromSyncModel( |
92 const sync_api::BaseTransaction* trans, | 92 const sync_api::BaseTransaction* trans, |
93 const sync_api::SyncManager::ChangeRecord* changes, | 93 const sync_api::SyncManager::ChangeRecord* changes, |
94 int change_count) { | 94 int change_count) { |
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
96 if (!running()) { | 96 if (!running()) { |
97 return; | 97 return; |
98 } | 98 } |
99 ExtensionsService* extensions_service = | 99 ExtensionService* extensions_service = |
100 GetExtensionsServiceFromProfile(profile_); | 100 GetExtensionServiceFromProfile(profile_); |
101 for (int i = 0; i < change_count; ++i) { | 101 for (int i = 0; i < change_count; ++i) { |
102 const sync_api::SyncManager::ChangeRecord& change = changes[i]; | 102 const sync_api::SyncManager::ChangeRecord& change = changes[i]; |
103 switch (change.action) { | 103 switch (change.action) { |
104 case sync_api::SyncManager::ChangeRecord::ACTION_ADD: | 104 case sync_api::SyncManager::ChangeRecord::ACTION_ADD: |
105 case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: { | 105 case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: { |
106 sync_api::ReadNode node(trans); | 106 sync_api::ReadNode node(trans); |
107 if (!node.InitByIdLookup(change.id)) { | 107 if (!node.InitByIdLookup(change.id)) { |
108 std::stringstream error; | 108 std::stringstream error; |
109 error << "Extension node lookup failed for change " << change.id | 109 error << "Extension node lookup failed for change " << change.id |
110 << " of action type " << change.action; | 110 << " of action type " << change.action; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 187 } |
188 | 188 |
189 void ExtensionChangeProcessor::StopObserving() { | 189 void ExtensionChangeProcessor::StopObserving() { |
190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
191 DCHECK(profile_); | 191 DCHECK(profile_); |
192 VLOG(1) << "Unobserving all notifications"; | 192 VLOG(1) << "Unobserving all notifications"; |
193 notification_registrar_.RemoveAll(); | 193 notification_registrar_.RemoveAll(); |
194 } | 194 } |
195 | 195 |
196 } // namespace browser_sync | 196 } // namespace browser_sync |
OLD | NEW |