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