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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 7981025: Use P2P Transport API by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - 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
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 "remoting/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 view_proxy_ = new PepperViewProxy(this, view_.get(), plugin_message_loop_); 149 view_proxy_ = new PepperViewProxy(this, view_.get(), plugin_message_loop_);
150 rectangle_decoder_ = new RectangleUpdateDecoder( 150 rectangle_decoder_ = new RectangleUpdateDecoder(
151 context_.decode_message_loop(), view_proxy_); 151 context_.decode_message_loop(), view_proxy_);
152 152
153 // Default to a medium grey. 153 // Default to a medium grey.
154 view_->SetSolidFill(0xFFCDCDCD); 154 view_->SetSolidFill(0xFFCDCDCD);
155 155
156 return true; 156 return true;
157 } 157 }
158 158
159 void ChromotingInstance::Connect(const ClientConfig& config, bool use_p2p_api) { 159 void ChromotingInstance::Connect(const ClientConfig& config) {
160 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); 160 DCHECK(plugin_message_loop_->BelongsToCurrentThread());
161 161
162 // This can only happen at initialization if the Javascript connect call 162 // This can only happen at initialization if the Javascript connect call
163 // occurs before the enterprise policy is read. We are guaranteed that the 163 // occurs before the enterprise policy is read. We are guaranteed that the
164 // enterprise policy is pushed at least once, we we delay the connect call. 164 // enterprise policy is pushed at least once, we we delay the connect call.
165 if (!initial_policy_received_) { 165 if (!initial_policy_received_) {
166 LOG(INFO) << "Delaying connect until initial policy is read."; 166 LOG(INFO) << "Delaying connect until initial policy is read.";
167 delayed_connect_.reset( 167 delayed_connect_.reset(
168 task_factory_.NewRunnableMethod(&ChromotingInstance::Connect, 168 task_factory_.NewRunnableMethod(&ChromotingInstance::Connect, config));
169 config, use_p2p_api));
170 return; 169 return;
171 } 170 }
172 171
173 webkit::ppapi::PluginInstance* plugin_instance = 172 host_connection_.reset(new protocol::ConnectionToHost(
174 webkit::ppapi::ResourceTracker::Get()->GetInstance(pp_instance()); 173 context_.network_message_loop(), this, NULL, NULL, NULL, NULL,
175 174 enable_client_nat_traversal_));
Wez 2011/09/22 11:24:56 Will the ConnectionToHost be updated in a subseque
Sergey Ulanov 2011/09/22 17:07:45 Yes.
176 if (use_p2p_api) {
177 host_connection_.reset(new protocol::ConnectionToHost(
178 context_.network_message_loop(), this, NULL, NULL, NULL, NULL,
179 enable_client_nat_traversal_));
180 } else {
181 content::P2PSocketDispatcher* socket_dispatcher =
182 plugin_instance->delegate()->GetP2PSocketDispatcher();
183
184 content::IpcNetworkManager* network_manager = NULL;
185 content::IpcPacketSocketFactory* socket_factory = NULL;
186 HostResolverFactory* host_resolver_factory = NULL;
187 PortAllocatorSessionFactory* session_factory =
188 CreatePepperPortAllocatorSessionFactory(
189 this, plugin_message_loop_, context_.network_message_loop());
190
191 // If we don't have socket dispatcher for IPC (e.g. P2P API is
192 // disabled), then JingleSessionManager will try to use physical sockets.
193 if (socket_dispatcher) {
194 VLOG(1) << "Creating IpcNetworkManager and IpcPacketSocketFactory.";
195 network_manager = new content::IpcNetworkManager(socket_dispatcher);
196 socket_factory = new content::IpcPacketSocketFactory(socket_dispatcher);
197 host_resolver_factory = new IpcHostResolverFactory(socket_dispatcher);
198 }
199
200 host_connection_.reset(new protocol::ConnectionToHost(
201 context_.network_message_loop(), NULL, network_manager, socket_factory,
202 host_resolver_factory, session_factory, enable_client_nat_traversal_));
203 }
204 175
205 input_handler_.reset(new PepperInputHandler(&context_, 176 input_handler_.reset(new PepperInputHandler(&context_,
206 host_connection_.get(), 177 host_connection_.get(),
207 view_proxy_)); 178 view_proxy_));
208 179
209 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), 180 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(),
210 view_proxy_, rectangle_decoder_.get(), 181 view_proxy_, rectangle_decoder_.get(),
211 input_handler_.get(), NULL)); 182 input_handler_.get(), NULL));
212 183
213 LOG(INFO) << "Connecting."; 184 LOG(INFO) << "Connecting.";
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 526 }
556 527
557 initial_policy_received_ = true; 528 initial_policy_received_ = true;
558 enable_client_nat_traversal_ = traversal_policy; 529 enable_client_nat_traversal_ = traversal_policy;
559 530
560 if (delayed_connect_.get()) 531 if (delayed_connect_.get())
561 plugin_message_loop_->PostTask(FROM_HERE, delayed_connect_.release()); 532 plugin_message_loop_->PostTask(FROM_HERE, delayed_connect_.release());
562 } 533 }
563 534
564 } // namespace remoting 535 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/chromoting_scriptable_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698