diff options
-rw-r--r-- | remoting/client/client_context.cc | 20 | ||||
-rw-r--r-- | remoting/client/client_context.h | 10 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 12 |
3 files changed, 32 insertions, 10 deletions
diff --git a/remoting/client/client_context.cc b/remoting/client/client_context.cc index 5f6d139..7e5ee7a 100644 --- a/remoting/client/client_context.cc +++ b/remoting/client/client_context.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,13 +7,15 @@ #include <string> #include "base/threading/thread.h" +#include "remoting/client/plugin/pepper_util.h" #include "remoting/jingle_glue/jingle_thread.h" namespace remoting { ClientContext::ClientContext() : main_thread_("ChromotingClientMainThread"), - decode_thread_("ChromotingClientDecodeThread") { + decode_thread_("ChromotingClientDecodeThread"), + started_(false) { } ClientContext::~ClientContext() { @@ -21,16 +23,22 @@ ClientContext::~ClientContext() { void ClientContext::Start() { // Start all the threads. + DCHECK(CurrentlyOnPluginThread()); main_thread_.Start(); decode_thread_.Start(); jingle_thread_.Start(); + started_ = true; } void ClientContext::Stop() { - // Stop all the threads. - jingle_thread_.Stop(); - decode_thread_.Stop(); - main_thread_.Stop(); + DCHECK(CurrentlyOnPluginThread()); + if (started_) { + // Stop all the threads. + jingle_thread_.Stop(); + decode_thread_.Stop(); + main_thread_.Stop(); + started_ = false; + } } JingleThread* ClientContext::jingle_thread() { diff --git a/remoting/client/client_context.h b/remoting/client/client_context.h index 38c6088..c28c62e 100644 --- a/remoting/client/client_context.h +++ b/remoting/client/client_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,12 +13,13 @@ namespace remoting { // A class that manages threads and running context for the chromoting client -// process. +// process. This class is not designed to be subclassed. class ClientContext { public: ClientContext(); - virtual ~ClientContext(); + ~ClientContext(); + // Start and Stop must be called from the main plugin thread. void Start(); void Stop(); @@ -40,6 +41,9 @@ class ClientContext { // A thread that handles all decode operations. base::Thread decode_thread_; + // True if Start() was called on the context. + bool started_; + DISALLOW_COPY_AND_ASSIGN(ClientContext); }; diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 6fabb24..6a5e1bb 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -21,6 +21,7 @@ // crbug.com/74951 #include "content/renderer/p2p/ipc_network_manager.h" #include "content/renderer/p2p/ipc_socket_factory.h" +#include "media/base/media.h" #include "ppapi/c/dev/ppb_query_policy_dev.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/input_event.h" @@ -121,7 +122,9 @@ ChromotingInstance::~ChromotingInstance() { // before we can call Detach() on |view_proxy_|. context_.Stop(); - view_proxy_->Detach(); + if (view_proxy_.get()) { + view_proxy_->Detach(); + } } bool ChromotingInstance::Init(uint32_t argc, @@ -132,6 +135,13 @@ bool ChromotingInstance::Init(uint32_t argc, VLOG(1) << "Started ChromotingInstance::Init"; + // Check to make sure the media library is initialized. + // http://crbug.com/91521. + if (!media::IsMediaLibraryInitialized()) { + logger_.Log(logging::LOG_ERROR, "Media library not initialized."); + return false; + } + // Start all the threads. context_.Start(); |