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

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

Issue 250001: Second attempt at the new syncer thread impl, now with less crashes!... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncer_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <iphlpapi.h> 11 #include <iphlpapi.h>
12 #endif 12 #endif
13 13
14 #include <iomanip> 14 #include <iomanip>
15 #include <list> 15 #include <list>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/at_exit.h" 19 #include "base/at_exit.h"
20 #include "base/basictypes.h" 20 #include "base/basictypes.h"
21 #include "base/command_line.h"
21 #include "base/scoped_ptr.h" 22 #include "base/scoped_ptr.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "chrome/browser/sync/engine/all_status.h" 24 #include "chrome/browser/sync/engine/all_status.h"
24 #include "chrome/browser/sync/engine/auth_watcher.h" 25 #include "chrome/browser/sync/engine/auth_watcher.h"
25 #include "chrome/browser/sync/engine/change_reorder_buffer.h" 26 #include "chrome/browser/sync/engine/change_reorder_buffer.h"
26 #include "chrome/browser/sync/engine/client_command_channel.h" 27 #include "chrome/browser/sync/engine/client_command_channel.h"
27 #include "chrome/browser/sync/engine/model_safe_worker.h" 28 #include "chrome/browser/sync/engine/model_safe_worker.h"
28 #include "chrome/browser/sync/engine/net/gaia_authenticator.h" 29 #include "chrome/browser/sync/engine/net/gaia_authenticator.h"
29 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 30 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
30 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" 31 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
(...skipping 15 matching lines...) Expand all
46 47
47 using browser_sync::AllStatus; 48 using browser_sync::AllStatus;
48 using browser_sync::AllStatusEvent; 49 using browser_sync::AllStatusEvent;
49 using browser_sync::AuthWatcher; 50 using browser_sync::AuthWatcher;
50 using browser_sync::AuthWatcherEvent; 51 using browser_sync::AuthWatcherEvent;
51 using browser_sync::ClientCommandChannel; 52 using browser_sync::ClientCommandChannel;
52 using browser_sync::Syncer; 53 using browser_sync::Syncer;
53 using browser_sync::SyncerEvent; 54 using browser_sync::SyncerEvent;
54 using browser_sync::SyncerStatus; 55 using browser_sync::SyncerStatus;
55 using browser_sync::SyncerThread; 56 using browser_sync::SyncerThread;
57 using browser_sync::SyncerThreadFactory;
56 using browser_sync::UserSettings; 58 using browser_sync::UserSettings;
57 using browser_sync::TalkMediator; 59 using browser_sync::TalkMediator;
58 using browser_sync::TalkMediatorImpl; 60 using browser_sync::TalkMediatorImpl;
59 using std::list; 61 using std::list;
60 using std::hex; 62 using std::hex;
61 using std::string; 63 using std::string;
62 using std::vector; 64 using std::vector;
63 using syncable::Directory; 65 using syncable::Directory;
64 using syncable::DirectoryManager; 66 using syncable::DirectoryManager;
65 67
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 Observer* observer_; 868 Observer* observer_;
867 869
868 // A sink for client commands from the syncer needed to create a SyncerThread. 870 // A sink for client commands from the syncer needed to create a SyncerThread.
869 ClientCommandChannel command_channel_; 871 ClientCommandChannel command_channel_;
870 872
871 // The ServerConnectionManager used to abstract communication between the 873 // The ServerConnectionManager used to abstract communication between the
872 // client (the Syncer) and the sync server. 874 // client (the Syncer) and the sync server.
873 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; 875 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_;
874 876
875 // The thread that runs the Syncer. Needs to be explicitly Start()ed. 877 // The thread that runs the Syncer. Needs to be explicitly Start()ed.
876 scoped_ptr<SyncerThread> syncer_thread_; 878 scoped_refptr<SyncerThread> syncer_thread_;
877 879
878 // Notification (xmpp) handler. 880 // Notification (xmpp) handler.
879 scoped_ptr<TalkMediator> talk_mediator_; 881 scoped_ptr<TalkMediator> talk_mediator_;
880 882
881 // A multi-purpose status watch object that aggregates stats from various 883 // A multi-purpose status watch object that aggregates stats from various
882 // sync components. 884 // sync components.
883 AllStatus allstatus_; 885 AllStatus allstatus_;
884 886
885 // AuthWatcher kicks off the authentication process and follows it through 887 // 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 888 // phase 1 (GAIA) to phase 2 (sync engine). As part of this work it determines
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 HttpPostProviderFactory* auth_post_factory, 990 HttpPostProviderFactory* auth_post_factory,
989 ModelSafeWorkerInterface* model_safe_worker, 991 ModelSafeWorkerInterface* model_safe_worker,
990 bool attempt_last_user_authentication, 992 bool attempt_last_user_authentication,
991 const char* user_agent) { 993 const char* user_agent) {
992 994
993 if (!g_log_files_initialized) { 995 if (!g_log_files_initialized) {
994 // TODO(timsteele): Call InitLogFiles() or equivalent. 996 // TODO(timsteele): Call InitLogFiles() or equivalent.
995 g_log_files_initialized = true; 997 g_log_files_initialized = true;
996 } 998 }
997 999
1000 // TODO(timsteele): We need to do this for syncapi.dll, but should remove
1001 // once we link statically. On windows this will set up the correct command
1002 // line, on posix it will be create an empty command line.
1003 CommandLine::Init(0, NULL);
1004
998 // Set up UserSettings, creating the db if necessary. We need this to 1005 // Set up UserSettings, creating the db if necessary. We need this to
999 // instantiate a URLFactory to give to the Syncer. 1006 // instantiate a URLFactory to give to the Syncer.
1000 PathString settings_db_file = AppendSlash(database_location) + 1007 PathString settings_db_file = AppendSlash(database_location) +
1001 kBookmarkSyncUserSettingsDatabase; 1008 kBookmarkSyncUserSettingsDatabase;
1002 user_settings_.reset(new UserSettings()); 1009 user_settings_.reset(new UserSettings());
1003 if (!user_settings_->Init(settings_db_file)) 1010 if (!user_settings_->Init(settings_db_file))
1004 return false; 1011 return false;
1005 1012
1006 share_.dir_manager.reset(new DirectoryManager(database_location)); 1013 share_.dir_manager.reset(new DirectoryManager(database_location));
1007 1014
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 talk_mediator()->WatchAuthWatcher(auth_watcher()); 1063 talk_mediator()->WatchAuthWatcher(auth_watcher());
1057 allstatus()->WatchAuthWatcher(auth_watcher()); 1064 allstatus()->WatchAuthWatcher(auth_watcher());
1058 authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(), 1065 authwatcher_hookup_.reset(NewEventListenerHookup(auth_watcher_->channel(),
1059 this, &SyncInternal::HandleAuthWatcherEvent)); 1066 this, &SyncInternal::HandleAuthWatcherEvent));
1060 1067
1061 // Tell the SyncerThread to use the ModelSafeWorker for bookmark model work. 1068 // Tell the SyncerThread to use the ModelSafeWorker for bookmark model work.
1062 // We set up both sides of the "bridge" here, with the ModelSafeWorkerBridge 1069 // 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. 1070 // on the Syncer side, and |model_safe_worker| on the API client side.
1064 ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker); 1071 ModelSafeWorkerBridge* worker = new ModelSafeWorkerBridge(model_safe_worker);
1065 1072
1066 syncer_thread_.reset(new SyncerThread(&command_channel_, 1073 syncer_thread_ = SyncerThreadFactory::Create(&command_channel_,
1067 dir_manager(), 1074 dir_manager(),
1068 connection_manager(), 1075 connection_manager(),
1069 &allstatus_, 1076 &allstatus_,
1070 worker)); 1077 worker);
1071 syncer_thread()->WatchTalkMediator(talk_mediator()); 1078 syncer_thread()->WatchTalkMediator(talk_mediator());
1072 allstatus()->WatchSyncerThread(syncer_thread()); 1079 allstatus()->WatchSyncerThread(syncer_thread());
1073 1080
1074 syncer_thread()->Start(); // Start the syncer thread. This won't actually 1081 syncer_thread()->Start(); // Start the syncer thread. This won't actually
1075 // result in any syncing until at least the 1082 // result in any syncing until at least the
1076 // DirectoryManager broadcasts the OPENED event, 1083 // DirectoryManager broadcasts the OPENED event,
1077 // and a valid server connection is detected. 1084 // and a valid server connection is detected.
1078 1085
1079 if (attempt_last_user_authentication) 1086 if (attempt_last_user_authentication)
1080 AuthenticateForLastKnownUser(); 1087 AuthenticateForLastKnownUser();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 BaseTransaction::~BaseTransaction() { 1567 BaseTransaction::~BaseTransaction() {
1561 delete lookup_; 1568 delete lookup_;
1562 } 1569 }
1563 1570
1564 UserShare* SyncManager::GetUserShare() const { 1571 UserShare* SyncManager::GetUserShare() const {
1565 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 1572 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
1566 return data_->GetUserShare(); 1573 return data_->GetUserShare();
1567 } 1574 }
1568 1575
1569 } // namespace sync_api 1576 } // namespace sync_api
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncer_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698