OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 using browser_sync::AllStatus; | 47 using browser_sync::AllStatus; |
48 using browser_sync::AllStatusEvent; | 48 using browser_sync::AllStatusEvent; |
49 using browser_sync::AuthWatcher; | 49 using browser_sync::AuthWatcher; |
50 using browser_sync::AuthWatcherEvent; | 50 using browser_sync::AuthWatcherEvent; |
51 using browser_sync::ClientCommandChannel; | 51 using browser_sync::ClientCommandChannel; |
52 using browser_sync::Syncer; | 52 using browser_sync::Syncer; |
53 using browser_sync::SyncerEvent; | 53 using browser_sync::SyncerEvent; |
54 using browser_sync::SyncerStatus; | 54 using browser_sync::SyncerStatus; |
55 using browser_sync::SyncerThread; | 55 using browser_sync::SyncerThread; |
| 56 using browser_sync::SyncerThreadFactory; |
56 using browser_sync::UserSettings; | 57 using browser_sync::UserSettings; |
57 using browser_sync::TalkMediator; | 58 using browser_sync::TalkMediator; |
58 using browser_sync::TalkMediatorImpl; | 59 using browser_sync::TalkMediatorImpl; |
59 using std::list; | 60 using std::list; |
60 using std::hex; | 61 using std::hex; |
61 using std::string; | 62 using std::string; |
62 using std::vector; | 63 using std::vector; |
63 using syncable::Directory; | 64 using syncable::Directory; |
64 using syncable::DirectoryManager; | 65 using syncable::DirectoryManager; |
65 | 66 |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 Observer* observer_; | 867 Observer* observer_; |
867 | 868 |
868 // A sink for client commands from the syncer needed to create a SyncerThread. | 869 // A sink for client commands from the syncer needed to create a SyncerThread. |
869 ClientCommandChannel command_channel_; | 870 ClientCommandChannel command_channel_; |
870 | 871 |
871 // The ServerConnectionManager used to abstract communication between the | 872 // The ServerConnectionManager used to abstract communication between the |
872 // client (the Syncer) and the sync server. | 873 // client (the Syncer) and the sync server. |
873 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; | 874 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; |
874 | 875 |
875 // The thread that runs the Syncer. Needs to be explicitly Start()ed. | 876 // The thread that runs the Syncer. Needs to be explicitly Start()ed. |
876 scoped_ptr<SyncerThread> syncer_thread_; | 877 scoped_refptr<SyncerThread> syncer_thread_; |
877 | 878 |
878 // Notification (xmpp) handler. | 879 // Notification (xmpp) handler. |
879 scoped_ptr<TalkMediator> talk_mediator_; | 880 scoped_ptr<TalkMediator> talk_mediator_; |
880 | 881 |
881 // A multi-purpose status watch object that aggregates stats from various | 882 // A multi-purpose status watch object that aggregates stats from various |
882 // sync components. | 883 // sync components. |
883 AllStatus allstatus_; | 884 AllStatus allstatus_; |
884 | 885 |
885 // AuthWatcher kicks off the authentication process and follows it through | 886 // AuthWatcher kicks off the authentication process and follows it through |
886 // phase 1 (GAIA) to phase 2 (sync engine). As part of this work it determines | 887 // phase 1 (GAIA) to phase 2 (sync engine). As part of this work it determines |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 talk_mediator()->WatchAuthWatcher(auth_watcher()); | 1057 talk_mediator()->WatchAuthWatcher(auth_watcher()); |
1057 allstatus()->WatchAuthWatcher(auth_watcher()); | 1058 allstatus()->WatchAuthWatcher(auth_watcher()); |
1058 authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(), | 1059 authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(), |
1059 this, &SyncInternal::HandleAuthWatcherEvent)); | 1060 this, &SyncInternal::HandleAuthWatcherEvent)); |
1060 | 1061 |
1061 // Tell the SyncerThread to use the ModelSafeWorker for bookmark model work. | 1062 // Tell the SyncerThread to use the ModelSafeWorker for bookmark model work. |
1062 // We set up both sides of the "bridge" here, with the ModelSafeWorkerBridge | 1063 // We set up both sides of the "bridge" here, with the ModelSafeWorkerBridge |
1063 // on the Syncer side, and |model_safe_worker| on the API client side. | 1064 // on the Syncer side, and |model_safe_worker| on the API client side. |
1064 ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker); | 1065 ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker); |
1065 | 1066 |
1066 syncer_thread_.reset(new SyncerThread(&command_channel_, | 1067 syncer_thread_ = SyncerThreadFactory::Create(&command_channel_, |
1067 dir_manager(), | 1068 dir_manager(), |
1068 connection_manager(), | 1069 connection_manager(), |
1069 &allstatus_, | 1070 &allstatus_, |
1070 worker)); | 1071 worker); |
1071 syncer_thread()->WatchTalkMediator(talk_mediator()); | 1072 syncer_thread()->WatchTalkMediator(talk_mediator()); |
1072 allstatus()->WatchSyncerThread(syncer_thread()); | 1073 allstatus()->WatchSyncerThread(syncer_thread()); |
1073 | 1074 |
1074 syncer_thread()->Start(); // Start the syncer thread. This won't actually | 1075 syncer_thread()->Start(); // Start the syncer thread. This won't actually |
1075 // result in any syncing until at least the | 1076 // result in any syncing until at least the |
1076 // DirectoryManager broadcasts the OPENED event, | 1077 // DirectoryManager broadcasts the OPENED event, |
1077 // and a valid server connection is detected. | 1078 // and a valid server connection is detected. |
1078 | 1079 |
1079 if (attempt_last_user_authentication) | 1080 if (attempt_last_user_authentication) |
1080 AuthenticateForLastKnownUser(); | 1081 AuthenticateForLastKnownUser(); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 BaseTransaction::~BaseTransaction() { | 1561 BaseTransaction::~BaseTransaction() { |
1561 delete lookup_; | 1562 delete lookup_; |
1562 } | 1563 } |
1563 | 1564 |
1564 UserShare* SyncManager::GetUserShare() const { | 1565 UserShare* SyncManager::GetUserShare() const { |
1565 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; | 1566 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; |
1566 return data_->GetUserShare(); | 1567 return data_->GetUserShare(); |
1567 } | 1568 } |
1568 | 1569 |
1569 } // namespace sync_api | 1570 } // namespace sync_api |
OLD | NEW |