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

Side by Side Diff: chrome/browser/sync/notifier/sync_notifier_factory.cc

Issue 7745040: [Sync] Make P2PNotifier behave more like InvalidationNotifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 years, 3 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 | « chrome/browser/sync/notifier/sync_notifier.h ('k') | chrome/browser/sync/syncable/model_type.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) 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 "chrome/browser/sync/notifier/sync_notifier_factory.h" 5 #include "chrome/browser/sync/notifier/sync_notifier_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h" 13 #include "chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h"
14 #include "chrome/browser/sync/notifier/p2p_notifier.h" 14 #include "chrome/browser/sync/notifier/p2p_notifier.h"
15 #include "chrome/browser/sync/notifier/sync_notifier.h" 15 #include "chrome/browser/sync/notifier/sync_notifier.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "jingle/notifier/base/const_communicator.h" 18 #include "jingle/notifier/base/const_communicator.h"
19 #include "jingle/notifier/base/notifier_options.h" 19 #include "jingle/notifier/base/notifier_options.h"
20 #include "jingle/notifier/listener/mediator_thread_impl.h"
21 #include "jingle/notifier/listener/talk_mediator_impl.h"
20 #include "net/base/host_port_pair.h" 22 #include "net/base/host_port_pair.h"
21 23
22 namespace sync_notifier { 24 namespace sync_notifier {
23 namespace { 25 namespace {
24 26
25 // TODO(akalin): Figure out whether this should be a method of 27 // TODO(akalin): Figure out whether this should be a method of
26 // HostPortPair. 28 // HostPortPair.
27 net::HostPortPair StringToHostPortPair(const std::string& host_port_str, 29 net::HostPortPair StringToHostPortPair(const std::string& host_port_str,
28 uint16 default_port) { 30 uint16 default_port) {
29 std::string::size_type colon_index = host_port_str.find(':'); 31 std::string::size_type colon_index = host_port_str.find(':');
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 85 }
84 86
85 if (command_line.HasSwitch(switches::kSyncNotificationMethod)) { 87 if (command_line.HasSwitch(switches::kSyncNotificationMethod)) {
86 const std::string notification_method_str( 88 const std::string notification_method_str(
87 command_line.GetSwitchValueASCII(switches::kSyncNotificationMethod)); 89 command_line.GetSwitchValueASCII(switches::kSyncNotificationMethod));
88 notifier_options.notification_method = 90 notifier_options.notification_method =
89 notifier::StringToNotificationMethod(notification_method_str); 91 notifier::StringToNotificationMethod(notification_method_str);
90 } 92 }
91 93
92 if (notifier_options.notification_method == notifier::NOTIFICATION_P2P) { 94 if (notifier_options.notification_method == notifier::NOTIFICATION_P2P) {
93 return new P2PNotifier(notifier_options); 95 notifier::TalkMediator* const talk_mediator =
96 new notifier::TalkMediatorImpl(
97 new notifier::MediatorThreadImpl(notifier_options),
98 notifier_options);
99 // Takes ownership of |talk_mediator|.
100 return new P2PNotifier(talk_mediator);
94 } 101 }
95 102
96 return new NonBlockingInvalidationNotifier(notifier_options, client_info); 103 return new NonBlockingInvalidationNotifier(notifier_options, client_info);
97 } 104 }
98 } // namespace 105 } // namespace
99 106
100 SyncNotifierFactory::SyncNotifierFactory( 107 SyncNotifierFactory::SyncNotifierFactory(
101 const std::string& client_info, 108 const std::string& client_info,
102 const scoped_refptr<net::URLRequestContextGetter>& 109 const scoped_refptr<net::URLRequestContextGetter>&
103 request_context_getter, 110 request_context_getter,
104 const CommandLine& command_line) 111 const CommandLine& command_line)
105 : client_info_(client_info), 112 : client_info_(client_info),
106 request_context_getter_(request_context_getter), 113 request_context_getter_(request_context_getter),
107 command_line_(command_line) { 114 command_line_(command_line) {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
109 } 116 }
110 117
111 SyncNotifierFactory::~SyncNotifierFactory() { 118 SyncNotifierFactory::~SyncNotifierFactory() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113 } 120 }
114 121
115 SyncNotifier* SyncNotifierFactory::CreateSyncNotifier() { 122 SyncNotifier* SyncNotifierFactory::CreateSyncNotifier() {
116 return CreateDefaultSyncNotifier(command_line_, 123 return CreateDefaultSyncNotifier(command_line_,
117 request_context_getter_, 124 request_context_getter_,
118 client_info_); 125 client_info_);
119 } 126 }
120 } // namespace sync_notifier 127 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/sync_notifier.h ('k') | chrome/browser/sync/syncable/model_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698