OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; | 52 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; |
53 | 53 |
54 typedef GoogleServiceAuthError AuthError; | 54 typedef GoogleServiceAuthError AuthError; |
55 | 55 |
56 namespace browser_sync { | 56 namespace browser_sync { |
57 | 57 |
58 using sessions::SyncSessionSnapshot; | 58 using sessions::SyncSessionSnapshot; |
59 using sync_api::SyncCredentials; | 59 using sync_api::SyncCredentials; |
60 | 60 |
61 SyncBackendHost::SyncBackendHost(Profile* profile) | 61 SyncBackendHost::SyncBackendHost(Profile* profile) |
62 : core_(new Core(ALLOW_THIS_IN_INITIALIZER_LIST(this))), | 62 : core_(new Core(profile->GetDebugName(), |
| 63 ALLOW_THIS_IN_INITIALIZER_LIST(this))), |
63 core_thread_("Chrome_SyncCoreThread"), | 64 core_thread_("Chrome_SyncCoreThread"), |
64 frontend_loop_(MessageLoop::current()), | 65 frontend_loop_(MessageLoop::current()), |
65 profile_(profile), | 66 profile_(profile), |
66 frontend_(NULL), | 67 frontend_(NULL), |
67 sync_data_folder_path_( | 68 sync_data_folder_path_( |
68 profile_->GetPath().Append(kSyncDataFolderName)), | 69 profile_->GetPath().Append(kSyncDataFolderName)), |
69 last_auth_error_(AuthError::None()), | 70 last_auth_error_(AuthError::None()), |
70 syncapi_initialized_(false) { | 71 syncapi_initialized_(false) { |
71 } | 72 } |
72 | 73 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 bool SyncBackendHost::HasUnsyncedItems() const { | 693 bool SyncBackendHost::HasUnsyncedItems() const { |
693 DCHECK(syncapi_initialized_); | 694 DCHECK(syncapi_initialized_); |
694 return core_->syncapi()->HasUnsyncedItems(); | 695 return core_->syncapi()->HasUnsyncedItems(); |
695 } | 696 } |
696 | 697 |
697 void SyncBackendHost::LogUnsyncedItems(int level) const { | 698 void SyncBackendHost::LogUnsyncedItems(int level) const { |
698 DCHECK(syncapi_initialized_); | 699 DCHECK(syncapi_initialized_); |
699 return core_->syncapi()->LogUnsyncedItems(level); | 700 return core_->syncapi()->LogUnsyncedItems(level); |
700 } | 701 } |
701 | 702 |
702 SyncBackendHost::Core::Core(SyncBackendHost* backend) | 703 SyncBackendHost::Core::Core(const std::string& name, SyncBackendHost* backend) |
703 : host_(backend), | 704 : host_(backend), |
704 syncapi_(new sync_api::SyncManager()), | 705 syncapi_(new sync_api::SyncManager(name)), |
705 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 706 sync_manager_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
706 parent_router_(NULL), | 707 parent_router_(NULL), |
707 processing_passphrase_(false), | 708 processing_passphrase_(false), |
708 deferred_nudge_for_cleanup_requested_(false) { | 709 deferred_nudge_for_cleanup_requested_(false) { |
709 } | 710 } |
710 | 711 |
711 // Helper to construct a user agent string (ASCII) suitable for use by | 712 // Helper to construct a user agent string (ASCII) suitable for use by |
712 // the syncapi for any HTTP communication. This string is used by the sync | 713 // the syncapi for any HTTP communication. This string is used by the sync |
713 // backend for classifying client types when calculating statistics. | 714 // backend for classifying client types when calculating statistics. |
714 std::string MakeUserAgentForSyncapi() { | 715 std::string MakeUserAgentForSyncapi() { |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); | 1200 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); |
1200 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); | 1201 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); |
1201 } | 1202 } |
1202 | 1203 |
1203 void SyncBackendHost::Core::DeferNudgeForCleanup() { | 1204 void SyncBackendHost::Core::DeferNudgeForCleanup() { |
1204 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); | 1205 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); |
1205 deferred_nudge_for_cleanup_requested_ = true; | 1206 deferred_nudge_for_cleanup_requested_ = true; |
1206 } | 1207 } |
1207 | 1208 |
1208 } // namespace browser_sync | 1209 } // namespace browser_sync |
OLD | NEW |