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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 9550009: [Sync] Move dependency on Chrome switches from SyncNotifierFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 9 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
OLDNEW
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 24 matching lines...) Expand all
35 #include "chrome/browser/sync/sessions/session_state.h" 35 #include "chrome/browser/sync/sessions/session_state.h"
36 #include "chrome/browser/sync/sync_prefs.h" 36 #include "chrome/browser/sync/sync_prefs.h"
37 #include "chrome/browser/sync/util/nigori.h" 37 #include "chrome/browser/sync/util/nigori.h"
38 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/chrome_version_info.h" 40 #include "chrome/common/chrome_version_info.h"
41 #include "chrome/common/net/gaia/gaia_constants.h" 41 #include "chrome/common/net/gaia/gaia_constants.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
44 #include "content/public/common/content_client.h" 44 #include "content/public/common/content_client.h"
45 #include "jingle/notifier/base/notification_method.h"
46 #include "jingle/notifier/base/notifier_options.h"
47 #include "net/base/host_port_pair.h"
48 #include "net/url_request/url_request_context_getter.h"
45 49
46 static const int kSaveChangesIntervalSeconds = 10; 50 static const int kSaveChangesIntervalSeconds = 10;
47 static const FilePath::CharType kSyncDataFolderName[] = 51 static const FilePath::CharType kSyncDataFolderName[] =
48 FILE_PATH_LITERAL("Sync Data"); 52 FILE_PATH_LITERAL("Sync Data");
49 53
50 typedef TokenService::TokenAvailableDetails TokenAvailableDetails; 54 typedef TokenService::TokenAvailableDetails TokenAvailableDetails;
51 55
52 typedef GoogleServiceAuthError AuthError; 56 typedef GoogleServiceAuthError AuthError;
53 57
54 namespace browser_sync { 58 namespace browser_sync {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 223
220 // Our encryptor, which uses Chrome's encryption functions. 224 // Our encryptor, which uses Chrome's encryption functions.
221 ChromeEncryptor encryptor_; 225 ChromeEncryptor encryptor_;
222 226
223 // The top-level syncapi entry point. Lives on the sync thread. 227 // The top-level syncapi entry point. Lives on the sync thread.
224 scoped_ptr<sync_api::SyncManager> sync_manager_; 228 scoped_ptr<sync_api::SyncManager> sync_manager_;
225 229
226 DISALLOW_COPY_AND_ASSIGN(Core); 230 DISALLOW_COPY_AND_ASSIGN(Core);
227 }; 231 };
228 232
233 namespace {
234
235 // Parses the given command line for notifier options.
236 notifier::NotifierOptions ParseNotifierOptions(
237 const CommandLine& command_line,
238 const scoped_refptr<net::URLRequestContextGetter>&
239 request_context_getter) {
240 notifier::NotifierOptions notifier_options;
241 notifier_options.request_context_getter = request_context_getter;
242
243 if (command_line.HasSwitch(switches::kSyncNotificationHostPort)) {
244 notifier_options.xmpp_host_port =
245 net::HostPortPair::FromString(
246 command_line.GetSwitchValueASCII(
247 switches::kSyncNotificationHostPort));
248 DVLOG(1) << "Using " << notifier_options.xmpp_host_port.ToString()
249 << " for test sync notification server.";
250 }
251
252 notifier_options.try_ssltcp_first =
253 command_line.HasSwitch(switches::kSyncTrySsltcpFirstForXmpp);
254 DVLOG_IF(1, notifier_options.try_ssltcp_first)
255 << "Trying SSL/TCP port before XMPP port for notifications.";
256
257 notifier_options.invalidate_xmpp_login =
258 command_line.HasSwitch(switches::kSyncInvalidateXmppLogin);
259 DVLOG_IF(1, notifier_options.invalidate_xmpp_login)
260 << "Invalidating sync XMPP login.";
261
262 notifier_options.allow_insecure_connection =
263 command_line.HasSwitch(switches::kSyncAllowInsecureXmppConnection);
264 DVLOG_IF(1, notifier_options.allow_insecure_connection)
265 << "Allowing insecure XMPP connections.";
266
267 if (command_line.HasSwitch(switches::kSyncNotificationMethod)) {
268 const std::string notification_method_str(
269 command_line.GetSwitchValueASCII(switches::kSyncNotificationMethod));
270 notifier_options.notification_method =
271 notifier::StringToNotificationMethod(notification_method_str);
272 }
273
274 return notifier_options;
275 }
276
277 } // namespace
278
229 SyncBackendHost::SyncBackendHost(const std::string& name, 279 SyncBackendHost::SyncBackendHost(const std::string& name,
230 Profile* profile, 280 Profile* profile,
231 const base::WeakPtr<SyncPrefs>& sync_prefs) 281 const base::WeakPtr<SyncPrefs>& sync_prefs)
232 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 282 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
233 sync_thread_("Chrome_SyncThread"), 283 sync_thread_("Chrome_SyncThread"),
234 frontend_loop_(MessageLoop::current()), 284 frontend_loop_(MessageLoop::current()),
235 profile_(profile), 285 profile_(profile),
236 name_(name), 286 name_(name),
237 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName), 287 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName),
238 weak_ptr_factory_.GetWeakPtr())), 288 weak_ptr_factory_.GetWeakPtr())),
239 initialization_state_(NOT_ATTEMPTED), 289 initialization_state_(NOT_ATTEMPTED),
240 sync_prefs_(sync_prefs), 290 sync_prefs_(sync_prefs),
241 chrome_sync_notification_bridge_(profile_), 291 chrome_sync_notification_bridge_(profile_),
242 sync_notifier_factory_( 292 sync_notifier_factory_(
293 ParseNotifierOptions(*CommandLine::ForCurrentProcess(),
294 profile_->GetRequestContext()),
243 content::GetUserAgent(GURL()), 295 content::GetUserAgent(GURL()),
244 profile_->GetRequestContext(), 296 sync_prefs),
245 sync_prefs,
246 *CommandLine::ForCurrentProcess()),
247 frontend_(NULL), 297 frontend_(NULL),
248 last_auth_error_(AuthError::None()) { 298 last_auth_error_(AuthError::None()) {
249 } 299 }
250 300
251 SyncBackendHost::SyncBackendHost(Profile* profile) 301 SyncBackendHost::SyncBackendHost(Profile* profile)
252 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 302 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
253 sync_thread_("Chrome_SyncThread"), 303 sync_thread_("Chrome_SyncThread"),
254 frontend_loop_(MessageLoop::current()), 304 frontend_loop_(MessageLoop::current()),
255 profile_(profile), 305 profile_(profile),
256 name_("Unknown"), 306 name_("Unknown"),
257 initialization_state_(NOT_ATTEMPTED), 307 initialization_state_(NOT_ATTEMPTED),
258 chrome_sync_notification_bridge_(profile_), 308 chrome_sync_notification_bridge_(profile_),
259 sync_notifier_factory_( 309 sync_notifier_factory_(
310 ParseNotifierOptions(*CommandLine::ForCurrentProcess(),
311 profile_->GetRequestContext()),
260 content::GetUserAgent(GURL()), 312 content::GetUserAgent(GURL()),
261 NULL, 313 base::WeakPtr<sync_notifier::InvalidationVersionTracker>()),
262 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
263 *CommandLine::ForCurrentProcess()),
264 frontend_(NULL), 314 frontend_(NULL),
265 last_auth_error_(AuthError::None()) { 315 last_auth_error_(AuthError::None()) {
266 } 316 }
267 317
268 SyncBackendHost::~SyncBackendHost() { 318 SyncBackendHost::~SyncBackendHost() {
269 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; 319 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor.";
270 DCHECK(!registrar_.get()); 320 DCHECK(!registrar_.get());
271 } 321 }
272 322
273 namespace { 323 namespace {
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 FROM_HERE, 1381 FROM_HERE,
1332 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1382 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1333 core_.get(), sync_thread_done_callback)); 1383 core_.get(), sync_thread_done_callback));
1334 } 1384 }
1335 1385
1336 #undef SDVLOG 1386 #undef SDVLOG
1337 1387
1338 #undef SLOG 1388 #undef SLOG
1339 1389
1340 } // namespace browser_sync 1390 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/notifier/sync_notifier_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698