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