| OLD | NEW |
| 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" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/task.h" | 16 #include "base/task.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 // TODO(sergeyu): We should not depend on renderer here. Instead P2P | 19 // TODO(sergeyu): We should not depend on renderer here. Instead P2P |
| 20 // Pepper API should be used. Remove this dependency. | 20 // Pepper API should be used. Remove this dependency. |
| 21 // crbug.com/74951 | 21 // crbug.com/74951 |
| 22 #include "content/renderer/p2p/ipc_network_manager.h" | 22 #include "content/renderer/p2p/ipc_network_manager.h" |
| 23 #include "content/renderer/p2p/ipc_socket_factory.h" | 23 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 24 #include "media/base/media.h" |
| 24 #include "ppapi/c/dev/ppb_query_policy_dev.h" | 25 #include "ppapi/c/dev/ppb_query_policy_dev.h" |
| 25 #include "ppapi/cpp/completion_callback.h" | 26 #include "ppapi/cpp/completion_callback.h" |
| 26 #include "ppapi/cpp/input_event.h" | 27 #include "ppapi/cpp/input_event.h" |
| 27 #include "ppapi/cpp/rect.h" | 28 #include "ppapi/cpp/rect.h" |
| 28 // TODO(wez): Remove this when crbug.com/86353 is complete. | 29 // TODO(wez): Remove this when crbug.com/86353 is complete. |
| 29 #include "ppapi/cpp/private/var_private.h" | 30 #include "ppapi/cpp/private/var_private.h" |
| 30 #include "remoting/client/client_config.h" | 31 #include "remoting/client/client_config.h" |
| 31 #include "remoting/client/chromoting_client.h" | 32 #include "remoting/client/chromoting_client.h" |
| 32 #include "remoting/client/rectangle_update_decoder.h" | 33 #include "remoting/client/rectangle_update_decoder.h" |
| 33 #include "remoting/client/plugin/chromoting_scriptable_object.h" | 34 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 base::WaitableEvent done_event(true, false); | 85 base::WaitableEvent done_event(true, false); |
| 85 client_->Stop(base::Bind(&base::WaitableEvent::Signal, | 86 client_->Stop(base::Bind(&base::WaitableEvent::Signal, |
| 86 base::Unretained(&done_event))); | 87 base::Unretained(&done_event))); |
| 87 done_event.Wait(); | 88 done_event.Wait(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 // Stopping the context shutdown all chromoting threads. This is a requirement | 91 // Stopping the context shutdown all chromoting threads. This is a requirement |
| 91 // before we can call Detach() on |view_proxy_|. | 92 // before we can call Detach() on |view_proxy_|. |
| 92 context_.Stop(); | 93 context_.Stop(); |
| 93 | 94 |
| 94 view_proxy_->Detach(); | 95 if (view_proxy_.get()) { |
| 96 view_proxy_->Detach(); |
| 97 } |
| 95 } | 98 } |
| 96 | 99 |
| 97 bool ChromotingInstance::Init(uint32_t argc, | 100 bool ChromotingInstance::Init(uint32_t argc, |
| 98 const char* argn[], | 101 const char* argn[], |
| 99 const char* argv[]) { | 102 const char* argv[]) { |
| 100 CHECK(!initialized_); | 103 CHECK(!initialized_); |
| 101 initialized_ = true; | 104 initialized_ = true; |
| 102 | 105 |
| 103 logger_.VLog(1, "Started ChromotingInstance::Init"); | 106 logger_.VLog(1, "Started ChromotingInstance::Init"); |
| 104 | 107 |
| 108 // Check to make sure the media library is initialized. |
| 109 // http://crbug.com/91521. |
| 110 if (!media::IsMediaLibraryInitialized()) { |
| 111 logger_.Log(logging::LOG_ERROR, "Media library not initialized."); |
| 112 return false; |
| 113 } |
| 114 |
| 105 // Start all the threads. | 115 // Start all the threads. |
| 106 context_.Start(); | 116 context_.Start(); |
| 107 | 117 |
| 108 SubscribeToNatTraversalPolicy(); | 118 SubscribeToNatTraversalPolicy(); |
| 109 | 119 |
| 110 // Create the chromoting objects that don't depend on the network connection. | 120 // Create the chromoting objects that don't depend on the network connection. |
| 111 view_.reset(new PepperView(this, &context_)); | 121 view_.reset(new PepperView(this, &context_)); |
| 112 view_proxy_ = new PepperViewProxy(this, view_.get()); | 122 view_proxy_ = new PepperViewProxy(this, view_.get()); |
| 113 rectangle_decoder_ = new RectangleUpdateDecoder( | 123 rectangle_decoder_ = new RectangleUpdateDecoder( |
| 114 context_.decode_message_loop(), view_proxy_); | 124 context_.decode_message_loop(), view_proxy_); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 449 |
| 440 initial_policy_received_ = true; | 450 initial_policy_received_ = true; |
| 441 enable_client_nat_traversal_ = traversal_policy; | 451 enable_client_nat_traversal_ = traversal_policy; |
| 442 | 452 |
| 443 if (delayed_connect_.get()) { | 453 if (delayed_connect_.get()) { |
| 444 RunTaskOnPluginThread(delayed_connect_.release()); | 454 RunTaskOnPluginThread(delayed_connect_.release()); |
| 445 } | 455 } |
| 446 } | 456 } |
| 447 | 457 |
| 448 } // namespace remoting | 458 } // namespace remoting |
| OLD | NEW |