Commit c52d1593 authored by dmaclach@chromium.org's avatar dmaclach@chromium.org

Future proof against things like http://crbug.com/91521

BUG=91521
TEST=Remove ffmpegsumo.so from a mac chrome build and attempt to use it as a client in a chromoting session.
     Check your logs. You should see Media library not initialized. Also, plugin shouldn't crash.

Review URL: http://codereview.chromium.org/7562016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95414 0039d316-1c4b-4281-b951-d872f2087c98
parent 001e6018
// 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() {
......
// 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);
};
......
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment