Skip to content

Commit

Permalink
Future proof against things like http://crbug.com/91521
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmaclach@chromium.org committed Aug 4, 2011
1 parent 001e601 commit c52d159
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
20 changes: 14 additions & 6 deletions remoting/client/client_context.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -7,30 +7,38 @@
#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() {
}

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() {
Expand Down
10 changes: 7 additions & 3 deletions remoting/client/client_context.h
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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();

Expand All @@ -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);
};

Expand Down
12 changes: 11 additions & 1 deletion remoting/client/plugin/chromoting_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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();

Expand Down

0 comments on commit c52d159

Please sign in to comment.