Skip to content

Commit

Permalink
Make InitializeMojo() idempotent.
Browse files Browse the repository at this point in the history
For tests, there are some difficulties to guarantee it being called just once.

This is a retake of https://codereview.chromium.org/866973004/,
which didn't work with some tests.

R=agl@chromium.org, sky@chromium.org
TEST=RenderThreadImplBrowserTest
BUG=

Review URL: https://codereview.chromium.org/872973003

Cr-Commit-Position: refs/heads/master@{#313139}
  • Loading branch information
omo authored and Commit bot committed Jan 26, 2015
1 parent dc3b3b4 commit e752220
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions content/app/mojo/mojo_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@

#include "content/app/mojo/mojo_init.h"

#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/mojo/src/mojo/edk/embedder/configuration.h"
#include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
#include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h"

namespace content {

namespace {

class MojoInitializer {
public:
MojoInitializer() {
mojo::embedder::GetConfiguration()->max_message_num_bytes =
64 * 1024 * 1024;
mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
}
};

base::LazyInstance<MojoInitializer>::Leaky mojo_initializer;

} // namespace

void InitializeMojo() {
// Things like content_shell and DevTools ocassionally send big
// message which includes whole rendered screen or all loaded
// scripts. The buffer size has to be big enough to allow such use
// cases.
mojo::embedder::GetConfiguration()->max_message_num_bytes = 64*1024*1024;
mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>(
new mojo::embedder::SimplePlatformSupport()));
mojo_initializer.Get();
}

} // namespace content

0 comments on commit e752220

Please sign in to comment.