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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 6182004: [SYNC] Refactor SyncSourceInfo and add support in chrome invalidation client ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Added util functions Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <iomanip> 8 #include <iomanip>
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 34 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
35 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 35 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
36 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 36 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
37 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 37 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
38 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" 38 #include "chrome/browser/sync/protocol/preference_specifics.pb.h"
39 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 39 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
40 #include "chrome/browser/sync/protocol/service_constants.h" 40 #include "chrome/browser/sync/protocol/service_constants.h"
41 #include "chrome/browser/sync/protocol/sync.pb.h" 41 #include "chrome/browser/sync/protocol/sync.pb.h"
42 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 42 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
43 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" 43 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
44 #include "chrome/browser/sync/sessions/sync_session.h"
44 #include "chrome/browser/sync/sessions/sync_session_context.h" 45 #include "chrome/browser/sync/sessions/sync_session_context.h"
45 #include "chrome/browser/sync/syncable/autofill_migration.h" 46 #include "chrome/browser/sync/syncable/autofill_migration.h"
46 #include "chrome/browser/sync/syncable/directory_manager.h" 47 #include "chrome/browser/sync/syncable/directory_manager.h"
47 #include "chrome/browser/sync/syncable/syncable.h" 48 #include "chrome/browser/sync/syncable/syncable.h"
48 #include "chrome/browser/sync/util/crypto_helpers.h" 49 #include "chrome/browser/sync/util/crypto_helpers.h"
49 #include "chrome/common/deprecated/event_sys.h" 50 #include "chrome/common/deprecated/event_sys.h"
50 #include "chrome/common/net/gaia/gaia_authenticator.h" 51 #include "chrome/common/net/gaia/gaia_authenticator.h"
51 #include "jingle/notifier/listener/mediator_thread_impl.h" 52 #include "jingle/notifier/listener/mediator_thread_impl.h"
52 #include "jingle/notifier/listener/notification_constants.h" 53 #include "jingle/notifier/listener/notification_constants.h"
53 #include "jingle/notifier/listener/talk_mediator.h" 54 #include "jingle/notifier/listener/talk_mediator.h"
(...skipping 22 matching lines...) Expand all
76 using syncable::Directory; 77 using syncable::Directory;
77 using syncable::DirectoryManager; 78 using syncable::DirectoryManager;
78 using syncable::Entry; 79 using syncable::Entry;
79 using syncable::SPECIFICS; 80 using syncable::SPECIFICS;
80 using sync_pb::AutofillProfileSpecifics; 81 using sync_pb::AutofillProfileSpecifics;
81 82
82 typedef GoogleServiceAuthError AuthError; 83 typedef GoogleServiceAuthError AuthError;
83 84
84 static const int kThreadExitTimeoutMsec = 60000; 85 static const int kThreadExitTimeoutMsec = 60000;
85 static const int kSSLPort = 443; 86 static const int kSSLPort = 443;
87 const int kSyncerThreadDelayMsec = 250;
86 88
87 #if defined(OS_CHROMEOS) 89 #if defined(OS_CHROMEOS)
88 static const int kChromeOSNetworkChangeReactionDelayHackMsec = 5000; 90 static const int kChromeOSNetworkChangeReactionDelayHackMsec = 5000;
89 #endif // OS_CHROMEOS 91 #endif // OS_CHROMEOS
90 92
91 // We manage the lifetime of sync_api::SyncManager::SyncInternal ourselves. 93 // We manage the lifetime of sync_api::SyncManager::SyncInternal ourselves.
92 DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_api::SyncManager::SyncInternal); 94 DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_api::SyncManager::SyncInternal);
93 95
94 namespace sync_api { 96 namespace sync_api {
95 97
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 DCHECK(!email.empty()); 2189 DCHECK(!email.empty());
2188 DCHECK(!token.empty()); 2190 DCHECK(!token.empty());
2189 InitializeTalkMediator(); 2191 InitializeTalkMediator();
2190 talk_mediator_->SetAuthToken(email, token, SYNC_SERVICE_NAME); 2192 talk_mediator_->SetAuthToken(email, token, SYNC_SERVICE_NAME);
2191 talk_mediator_->Login(); 2193 talk_mediator_->Login();
2192 } 2194 }
2193 2195
2194 void SyncManager::SyncInternal::OnIncomingNotification( 2196 void SyncManager::SyncInternal::OnIncomingNotification(
2195 const IncomingNotificationData& notification_data) { 2197 const IncomingNotificationData& notification_data) {
2196 syncable::ModelTypeBitSet model_types; 2198 syncable::ModelTypeBitSet model_types;
2199 browser_sync::sessions::ModelTypeMap model_types_with_payloads;
2197 2200
2198 // Check if the service url is a sync URL. An empty service URL is 2201 // Check if the service url is a sync URL. An empty service URL is
2199 // treated as a legacy sync notification. If we're listening to 2202 // treated as a legacy sync notification. If we're listening to
2200 // server-issued notifications, no need to check the service_url. 2203 // server-issued notifications, no need to check the service_url.
2201 if (notifier_options_.notification_method == 2204 if (notifier_options_.notification_method ==
2202 notifier::NOTIFICATION_SERVER) { 2205 notifier::NOTIFICATION_SERVER) {
2203 VLOG(1) << "Sync received server notification: " << 2206 VLOG(1) << "Sync received server notification from " <<
2207 notification_data.service_url << ": " <<
2208 notification_data.service_specific_data;
2209 const std::string& model_type_list = notification_data.service_url;
2210 const std::string& notification_payload =
2204 notification_data.service_specific_data; 2211 notification_data.service_specific_data;
2205 2212
2206 if (!syncable::ModelTypeBitSetFromString( 2213 if (!syncable::ModelTypeBitSetFromString(model_type_list, &model_types)) {
2207 notification_data.service_specific_data,
2208 &model_types)) {
2209 LOG(DFATAL) << "Could not extract model types from server data."; 2214 LOG(DFATAL) << "Could not extract model types from server data.";
2210 model_types.set(); 2215 model_types.set();
2211 } 2216 }
2217
2218 browser_sync::sessions::BuildModelTypeMapFromModelTypeBitSet(
2219 model_types,
2220 notification_payload,
2221 &model_types_with_payloads);
2212 } else if (notification_data.service_url.empty() || 2222 } else if (notification_data.service_url.empty() ||
2213 (notification_data.service_url == 2223 (notification_data.service_url ==
2214 browser_sync::kSyncLegacyServiceUrl) || 2224 browser_sync::kSyncLegacyServiceUrl) ||
2215 (notification_data.service_url == 2225 (notification_data.service_url ==
2216 browser_sync::kSyncServiceUrl)) { 2226 browser_sync::kSyncServiceUrl)) {
2217 VLOG(1) << "Sync received P2P notification."; 2227 VLOG(1) << "Sync received P2P notification.";
2218 2228
2219 // Catch for sync integration tests (uses p2p). Just set all datatypes. 2229 // Catch for sync integration tests (uses p2p). Just set all datatypes.
2220 model_types.set(); 2230 model_types.set();
2231 browser_sync::sessions::BuildModelTypeMapFromModelTypeBitSet(
2232 model_types,
2233 std::string(),
2234 &model_types_with_payloads);
2221 } else { 2235 } else {
2222 LOG(WARNING) << "Notification fron unexpected source: " 2236 LOG(WARNING) << "Notification fron unexpected source: "
2223 << notification_data.service_url; 2237 << notification_data.service_url;
2224 } 2238 }
2225 2239
2226 if (model_types.any()) { 2240 if (model_types.any()) {
2227 if (syncer_thread()) { 2241 if (syncer_thread()) {
2228 // Introduce a delay to help coalesce initial notifications. 2242 syncer_thread()->NudgeSyncerWithPayloads(
2229 syncer_thread()->NudgeSyncerWithDataTypes( 2243 kSyncerThreadDelayMsec,
2230 250, 2244 SyncerThread::kNotification,
2231 SyncerThread::kNotification, 2245 model_types_with_payloads);
2232 model_types);
2233 } 2246 }
2234 allstatus_.IncrementNotificationsReceived(); 2247 allstatus_.IncrementNotificationsReceived();
2235 } else { 2248 } else {
2236 LOG(WARNING) << "Sync received notification without any type information."; 2249 LOG(WARNING) << "Sync received notification without any type information.";
2237 } 2250 }
2238 } 2251 }
2239 2252
2240 void SyncManager::SyncInternal::OnOutgoingNotification() { 2253 void SyncManager::SyncInternal::OnOutgoingNotification() {
2241 DCHECK_NE(notifier_options_.notification_method, 2254 DCHECK_NE(notifier_options_.notification_method,
2242 notifier::NOTIFICATION_SERVER); 2255 notifier::NOTIFICATION_SERVER);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 2315 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
2303 return data_->GetUserShare(); 2316 return data_->GetUserShare();
2304 } 2317 }
2305 2318
2306 bool SyncManager::HasUnsyncedItems() const { 2319 bool SyncManager::HasUnsyncedItems() const {
2307 sync_api::ReadTransaction trans(GetUserShare()); 2320 sync_api::ReadTransaction trans(GetUserShare());
2308 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 2321 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
2309 } 2322 }
2310 2323
2311 } // namespace sync_api 2324 } // namespace sync_api
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698