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/base/task_thread_proxy.h" | 31 #include "remoting/base/task_thread_proxy.h" |
31 #include "remoting/base/util.h" | 32 #include "remoting/base/util.h" |
32 #include "remoting/client/client_config.h" | 33 #include "remoting/client/client_config.h" |
33 #include "remoting/client/chromoting_client.h" | 34 #include "remoting/client/chromoting_client.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::WaitableEvent done_event(true, false); | 115 base::WaitableEvent done_event(true, false); |
115 client_->Stop(base::Bind(&base::WaitableEvent::Signal, | 116 client_->Stop(base::Bind(&base::WaitableEvent::Signal, |
116 base::Unretained(&done_event))); | 117 base::Unretained(&done_event))); |
117 done_event.Wait(); | 118 done_event.Wait(); |
118 } | 119 } |
119 | 120 |
120 // Stopping the context shutdown all chromoting threads. This is a requirement | 121 // Stopping the context shutdown all chromoting threads. This is a requirement |
121 // before we can call Detach() on |view_proxy_|. | 122 // before we can call Detach() on |view_proxy_|. |
122 context_.Stop(); | 123 context_.Stop(); |
123 | 124 |
124 view_proxy_->Detach(); | 125 if (view_proxy_.get()) { |
| 126 view_proxy_->Detach(); |
| 127 } |
125 } | 128 } |
126 | 129 |
127 bool ChromotingInstance::Init(uint32_t argc, | 130 bool ChromotingInstance::Init(uint32_t argc, |
128 const char* argn[], | 131 const char* argn[], |
129 const char* argv[]) { | 132 const char* argv[]) { |
130 CHECK(!initialized_); | 133 CHECK(!initialized_); |
131 initialized_ = true; | 134 initialized_ = true; |
132 | 135 |
133 VLOG(1) << "Started ChromotingInstance::Init"; | 136 VLOG(1) << "Started ChromotingInstance::Init"; |
134 | 137 |
| 138 // Check to make sure the media library is initialized. |
| 139 // http://crbug.com/91521. |
| 140 if (!media::IsMediaLibraryInitialized()) { |
| 141 LOG(ERROR) << "Media library not initialized."; |
| 142 return false; |
| 143 } |
| 144 |
135 // Start all the threads. | 145 // Start all the threads. |
136 context_.Start(); | 146 context_.Start(); |
137 | 147 |
138 SubscribeToNatTraversalPolicy(); | 148 SubscribeToNatTraversalPolicy(); |
139 | 149 |
140 // Create the chromoting objects that don't depend on the network connection. | 150 // Create the chromoting objects that don't depend on the network connection. |
141 view_.reset(new PepperView(this, &context_)); | 151 view_.reset(new PepperView(this, &context_)); |
142 view_proxy_ = new PepperViewProxy(this, view_.get()); | 152 view_proxy_ = new PepperViewProxy(this, view_.get()); |
143 rectangle_decoder_ = new RectangleUpdateDecoder( | 153 rectangle_decoder_ = new RectangleUpdateDecoder( |
144 context_.decode_message_loop(), view_proxy_); | 154 context_.decode_message_loop(), view_proxy_); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 490 |
481 initial_policy_received_ = true; | 491 initial_policy_received_ = true; |
482 enable_client_nat_traversal_ = traversal_policy; | 492 enable_client_nat_traversal_ = traversal_policy; |
483 | 493 |
484 if (delayed_connect_.get()) { | 494 if (delayed_connect_.get()) { |
485 RunTaskOnPluginThread(delayed_connect_.release()); | 495 RunTaskOnPluginThread(delayed_connect_.release()); |
486 } | 496 } |
487 } | 497 } |
488 | 498 |
489 } // namespace remoting | 499 } // namespace remoting |
OLD | NEW |