| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/timer.h" | 21 #include "base/timer.h" |
| 22 #include "base/tracked_objects.h" | 22 #include "base/tracked_objects.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/signin/token_service.h" | 26 #include "chrome/browser/signin/token_service.h" |
| 27 #include "chrome/browser/sync/glue/bridged_invalidator.h" | 27 #include "chrome/browser/sync/glue/bridged_invalidator.h" |
| 28 #include "chrome/browser/sync/glue/change_processor.h" | 28 #include "chrome/browser/sync/glue/change_processor.h" |
| 29 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 29 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
| 30 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" | 30 #include "chrome/browser/sync/glue/chrome_sync_notification_bridge.h" |
| 31 #include "chrome/browser/sync/glue/device_info.h" |
| 31 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 32 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| 32 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 33 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 33 #include "chrome/browser/sync/sync_prefs.h" | 34 #include "chrome/browser/sync/sync_prefs.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/chrome_version_info.h" | 37 #include "chrome/common/chrome_version_info.h" |
| 37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/common/content_client.h" | 40 #include "content/public/common/content_client.h" |
| 40 #include "google_apis/gaia/gaia_constants.h" | 41 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 350 } |
| 350 | 351 |
| 351 SyncBackendHost::~SyncBackendHost() { | 352 SyncBackendHost::~SyncBackendHost() { |
| 352 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; | 353 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; |
| 353 DCHECK(!chrome_sync_notification_bridge_.get()); | 354 DCHECK(!chrome_sync_notification_bridge_.get()); |
| 354 DCHECK(!registrar_.get()); | 355 DCHECK(!registrar_.get()); |
| 355 } | 356 } |
| 356 | 357 |
| 357 namespace { | 358 namespace { |
| 358 | 359 |
| 359 // Helper to construct a user agent string (ASCII) suitable for use by | |
| 360 // the syncapi for any HTTP communication. This string is used by the sync | |
| 361 // backend for classifying client types when calculating statistics. | |
| 362 std::string MakeUserAgentForSyncApi() { | |
| 363 std::string user_agent; | |
| 364 user_agent = "Chrome "; | |
| 365 #if defined(OS_WIN) | |
| 366 user_agent += "WIN "; | |
| 367 #elif defined(OS_CHROMEOS) | |
| 368 user_agent += "CROS "; | |
| 369 #elif defined(OS_ANDROID) | |
| 370 user_agent += "ANDROID "; | |
| 371 #elif defined(OS_LINUX) | |
| 372 user_agent += "LINUX "; | |
| 373 #elif defined(OS_FREEBSD) | |
| 374 user_agent += "FREEBSD "; | |
| 375 #elif defined(OS_OPENBSD) | |
| 376 user_agent += "OPENBSD "; | |
| 377 #elif defined(OS_MACOSX) | |
| 378 user_agent += "MAC "; | |
| 379 #endif | |
| 380 chrome::VersionInfo version_info; | |
| 381 if (!version_info.is_valid()) { | |
| 382 DLOG(ERROR) << "Unable to create chrome::VersionInfo object"; | |
| 383 return user_agent; | |
| 384 } | |
| 385 | |
| 386 user_agent += version_info.Version(); | |
| 387 user_agent += " (" + version_info.LastChange() + ")"; | |
| 388 if (!version_info.IsOfficialBuild()) | |
| 389 user_agent += "-devel"; | |
| 390 return user_agent; | |
| 391 } | |
| 392 | |
| 393 scoped_ptr<syncer::HttpPostProviderFactory> MakeHttpBridgeFactory( | 360 scoped_ptr<syncer::HttpPostProviderFactory> MakeHttpBridgeFactory( |
| 394 const scoped_refptr<net::URLRequestContextGetter>& getter) { | 361 const scoped_refptr<net::URLRequestContextGetter>& getter) { |
| 362 chrome::VersionInfo version_info; |
| 395 return scoped_ptr<syncer::HttpPostProviderFactory>( | 363 return scoped_ptr<syncer::HttpPostProviderFactory>( |
| 396 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); | 364 new syncer::HttpBridgeFactory( |
| 365 getter, DeviceInfo::MakeUserAgentForSyncApi(version_info))); |
| 397 } | 366 } |
| 398 | 367 |
| 399 } // namespace | 368 } // namespace |
| 400 | 369 |
| 401 void SyncBackendHost::Initialize( | 370 void SyncBackendHost::Initialize( |
| 402 SyncFrontend* frontend, | 371 SyncFrontend* frontend, |
| 403 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 372 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 404 const GURL& sync_service_url, | 373 const GURL& sync_service_url, |
| 405 const SyncCredentials& credentials, | 374 const SyncCredentials& credentials, |
| 406 bool delete_sync_data_folder, | 375 bool delete_sync_data_folder, |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 const syncer::ModelTypeSet failed_configuration_types) { | 1513 const syncer::ModelTypeSet failed_configuration_types) { |
| 1545 HandleInitializationCompletedOnFrontendLoop( | 1514 HandleInitializationCompletedOnFrontendLoop( |
| 1546 failed_configuration_types.Empty()); | 1515 failed_configuration_types.Empty()); |
| 1547 } | 1516 } |
| 1548 | 1517 |
| 1549 #undef SDVLOG | 1518 #undef SDVLOG |
| 1550 | 1519 |
| 1551 #undef SLOG | 1520 #undef SLOG |
| 1552 | 1521 |
| 1553 } // namespace browser_sync | 1522 } // namespace browser_sync |
| OLD | NEW |