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

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

Issue 285243003: Revert 271343 "Build remoting for PNaCl" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 "remoting/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #if defined(OS_NACL)
12 #include <sys/mount.h>
13 #include <nacl_io/nacl_io.h>
14 #endif
15
16 #include "base/bind.h" 11 #include "base/bind.h"
17 #include "base/callback.h" 12 #include "base/callback.h"
18 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
19 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
20 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
21 #include "base/logging.h" 16 #include "base/logging.h"
22 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
23 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
24 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
25 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
26 #include "base/values.h" 21 #include "base/values.h"
27 #include "crypto/random.h" 22 #include "crypto/random.h"
28 #include "jingle/glue/thread_wrapper.h" 23 #include "jingle/glue/thread_wrapper.h"
29 #include "media/base/yuv_convert.h" 24 #include "media/base/media.h"
30 #include "net/socket/ssl_server_socket.h" 25 #include "net/socket/ssl_server_socket.h"
31 #include "ppapi/cpp/completion_callback.h" 26 #include "ppapi/cpp/completion_callback.h"
32 #include "ppapi/cpp/dev/url_util_dev.h" 27 #include "ppapi/cpp/dev/url_util_dev.h"
33 #include "ppapi/cpp/image_data.h" 28 #include "ppapi/cpp/image_data.h"
34 #include "ppapi/cpp/input_event.h" 29 #include "ppapi/cpp/input_event.h"
35 #include "ppapi/cpp/rect.h" 30 #include "ppapi/cpp/rect.h"
36 #include "ppapi/cpp/var_array_buffer.h" 31 #include "ppapi/cpp/var_array_buffer.h"
37 #include "ppapi/cpp/var_dictionary.h" 32 #include "ppapi/cpp/var_dictionary.h"
38 #include "remoting/base/constants.h" 33 #include "remoting/base/constants.h"
39 #include "remoting/base/util.h" 34 #include "remoting/base/util.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 initialized_(false), 203 initialized_(false),
209 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)), 204 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)),
210 context_(plugin_task_runner_.get()), 205 context_(plugin_task_runner_.get()),
211 input_tracker_(&mouse_input_filter_), 206 input_tracker_(&mouse_input_filter_),
212 key_mapper_(&input_tracker_), 207 key_mapper_(&input_tracker_),
213 normalizing_input_filter_(CreateNormalizingInputFilter(&key_mapper_)), 208 normalizing_input_filter_(CreateNormalizingInputFilter(&key_mapper_)),
214 input_handler_(this, normalizing_input_filter_.get()), 209 input_handler_(this, normalizing_input_filter_.get()),
215 use_async_pin_dialog_(false), 210 use_async_pin_dialog_(false),
216 use_media_source_rendering_(false), 211 use_media_source_rendering_(false),
217 weak_factory_(this) { 212 weak_factory_(this) {
218 #if defined(OS_NACL)
219 // In NaCl global resources need to be initialized differently because they
220 // are not shared with Chrome.
221 thread_task_runner_handle_.reset(
222 new base::ThreadTaskRunnerHandle(plugin_task_runner_));
223 thread_wrapper_.reset(
224 new jingle_glue::JingleThreadWrapper(plugin_task_runner_));
225 media::InitializeCPUSpecificYUVConversions();
226 #else
227 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
228 #endif
229
230 #if defined(OS_NACL)
231 nacl_io_init_ppapi(pp_instance, pp::Module::Get()->get_browser_interface());
232 mount("", "/etc", "memfs", 0, "");
233 mount("", "/usr", "memfs", 0, "");
234 #endif
235
236 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); 213 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL);
237 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); 214 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
238 215
239 // Resister this instance to handle debug log messsages. 216 // Resister this instance to handle debug log messsages.
240 RegisterLoggingInstance(); 217 RegisterLoggingInstance();
241 218
242 #if defined(USE_OPENSSL) 219 #if defined(USE_OPENSSL)
243 // Initialize random seed for libjingle. It's necessary only with OpenSSL. 220 // Initialize random seed for libjingle. It's necessary only with OpenSSL.
244 char random_seed[kRandomSeedSize]; 221 char random_seed[kRandomSeedSize];
245 crypto::RandBytes(random_seed, sizeof(random_seed)); 222 crypto::RandBytes(random_seed, sizeof(random_seed));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 257 }
281 258
282 bool ChromotingInstance::Init(uint32_t argc, 259 bool ChromotingInstance::Init(uint32_t argc,
283 const char* argn[], 260 const char* argn[],
284 const char* argv[]) { 261 const char* argv[]) {
285 CHECK(!initialized_); 262 CHECK(!initialized_);
286 initialized_ = true; 263 initialized_ = true;
287 264
288 VLOG(1) << "Started ChromotingInstance::Init"; 265 VLOG(1) << "Started ChromotingInstance::Init";
289 266
290 // Check that the calling content is part of an app or extension. This is only 267 // Check to make sure the media library is initialized.
291 // necessary for non-PNaCl version of the plugin. Also PPB_URLUtil_Dev doesn't 268 // http://crbug.com/91521.
292 // work in NaCl at the moment so the check fails in NaCl builds. 269 if (!media::IsMediaLibraryInitialized()) {
293 #if !defined(OS_NACL) 270 LOG(ERROR) << "Media library not initialized.";
271 return false;
272 }
273
274 // Check that the calling content is part of an app or extension.
294 if (!IsCallerAppOrExtension()) { 275 if (!IsCallerAppOrExtension()) {
295 LOG(ERROR) << "Not an app or extension"; 276 LOG(ERROR) << "Not an app or extension";
296 return false; 277 return false;
297 } 278 }
298 #endif
299 279
300 // Start all the threads. 280 // Start all the threads.
301 context_.Start(); 281 context_.Start();
302 282
303 return true; 283 return true;
304 } 284 }
305 285
306 void ChromotingInstance::HandleMessage(const pp::Var& message) { 286 void ChromotingInstance::HandleMessage(const pp::Var& message) {
307 if (!message.is_string()) { 287 if (!message.is_string()) {
308 LOG(ERROR) << "Received a message that is not a string."; 288 LOG(ERROR) << "Received a message that is not a string.";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } else if (method == "allowMouseLock") { 338 } else if (method == "allowMouseLock") {
359 HandleAllowMouseLockMessage(); 339 HandleAllowMouseLockMessage();
360 } else if (method == "enableMediaSourceRendering") { 340 } else if (method == "enableMediaSourceRendering") {
361 HandleEnableMediaSourceRendering(); 341 HandleEnableMediaSourceRendering();
362 } 342 }
363 } 343 }
364 344
365 void ChromotingInstance::DidChangeFocus(bool has_focus) { 345 void ChromotingInstance::DidChangeFocus(bool has_focus) {
366 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 346 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
367 347
368 if (!IsConnected())
369 return;
370
371 input_handler_.DidChangeFocus(has_focus); 348 input_handler_.DidChangeFocus(has_focus);
372 } 349 }
373 350
374 void ChromotingInstance::DidChangeView(const pp::View& view) { 351 void ChromotingInstance::DidChangeView(const pp::View& view) {
375 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 352 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
376 353
377 plugin_view_ = view; 354 plugin_view_ = view;
378 mouse_input_filter_.set_input_size( 355 mouse_input_filter_.set_input_size(
379 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height())); 356 webrtc::DesktopSize(view.GetRect().width(), view.GetRect().height()));
380 357
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 } 620 }
644 } 621 }
645 622
646 ConnectWithConfig(config, local_jid); 623 ConnectWithConfig(config, local_jid);
647 } 624 }
648 625
649 void ChromotingInstance::ConnectWithConfig(const ClientConfig& config, 626 void ChromotingInstance::ConnectWithConfig(const ClientConfig& config,
650 const std::string& local_jid) { 627 const std::string& local_jid) {
651 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 628 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
652 629
630 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
631
653 if (use_media_source_rendering_) { 632 if (use_media_source_rendering_) {
654 video_renderer_.reset(new MediaSourceVideoRenderer(this)); 633 video_renderer_.reset(new MediaSourceVideoRenderer(this));
655 } else { 634 } else {
656 view_.reset(new PepperView(this, &context_)); 635 view_.reset(new PepperView(this, &context_));
657 view_weak_factory_.reset( 636 view_weak_factory_.reset(
658 new base::WeakPtrFactory<FrameConsumer>(view_.get())); 637 new base::WeakPtrFactory<FrameConsumer>(view_.get()));
659 638
660 // SoftwareVideoRenderer runs on a separate thread so for now we wrap 639 // SoftwareVideoRenderer runs on a separate thread so for now we wrap
661 // PepperView with a ref-counted proxy object. 640 // PepperView with a ref-counted proxy object.
662 scoped_refptr<FrameConsumerProxy> consumer_proxy = 641 scoped_refptr<FrameConsumerProxy> consumer_proxy =
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 pp::VarArrayBuffer array_buffer(buffer_size); 1123 pp::VarArrayBuffer array_buffer(buffer_size);
1145 void* data_ptr = array_buffer.Map(); 1124 void* data_ptr = array_buffer.Map();
1146 memcpy(data_ptr, buffer, buffer_size); 1125 memcpy(data_ptr, buffer, buffer_size);
1147 array_buffer.Unmap(); 1126 array_buffer.Unmap();
1148 pp::VarDictionary data_dictionary; 1127 pp::VarDictionary data_dictionary;
1149 data_dictionary.Set(pp::Var("buffer"), array_buffer); 1128 data_dictionary.Set(pp::Var("buffer"), array_buffer);
1150 PostChromotingMessage("mediaSourceData", data_dictionary); 1129 PostChromotingMessage("mediaSourceData", data_dictionary);
1151 } 1130 }
1152 1131
1153 } // namespace remoting 1132 } // namespace remoting
OLDNEW
« no previous file with comments | « trunk/src/remoting/client/plugin/chromoting_instance.h ('k') | trunk/src/remoting/client/plugin/pepper_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698