Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: mojo/environment/environment.cc

Issue 1997473005: Remove requirement that mojo::Environment be instantiated. (Closed) Base URL: https://github.com/domokit/mojo.git@work797_no_utility_tls
Patch Set: SetDefaultAsyncWaiter Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/cpp/application/lib/application_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/public/cpp/environment/environment.h" 5 #include "mojo/public/cpp/environment/environment.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/environment/default_async_waiter.h" 8 #include "mojo/environment/default_async_waiter.h"
9 #include "mojo/environment/default_logger.h" 9 #include "mojo/environment/default_logger.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 // These methods are intentionally not implemented so that there is a link 13 // TODO(vtl): Probably we should share the following async waiter and logger
14 // error if someone uses them in a Chromium-environment. 14 // code with the "standalone" implementation. (The only difference is what the
15 #if 0 15 // |internal::kDefault...| are.)
16 Environment::Environment() {
17 }
18 16
19 Environment::Environment(const MojoAsyncWaiter* default_async_waiter, 17 const MojoAsyncWaiter* g_default_async_waiter = &internal::kDefaultAsyncWaiter;
20 const MojoLogger* default_logger) { 18 const MojoLogger* g_default_logger = &internal::kDefaultLogger;
21 }
22
23 Environment::~Environment() {
24 }
25 #endif
26 19
27 // static 20 // static
28 const MojoAsyncWaiter* Environment::GetDefaultAsyncWaiter() { 21 const MojoAsyncWaiter* Environment::GetDefaultAsyncWaiter() {
29 return &internal::kDefaultAsyncWaiter; 22 return g_default_async_waiter;
23 }
24
25 // static
26 void Environment::SetDefaultAsyncWaiter(const MojoAsyncWaiter* async_waiter) {
27 g_default_async_waiter =
28 async_waiter ? async_waiter : &internal::kDefaultAsyncWaiter;
30 } 29 }
31 30
32 // static 31 // static
33 const MojoLogger* Environment::GetDefaultLogger() { 32 const MojoLogger* Environment::GetDefaultLogger() {
34 return &internal::kDefaultLogger; 33 return g_default_logger;
35 } 34 }
36 35
37 // static 36 // static
38 void Environment::SetDefaultLogger(const MojoLogger* logger) {} 37 void Environment::SetDefaultLogger(const MojoLogger* logger) {
38 g_default_logger = logger ? logger : &internal::kDefaultLogger;
39 }
39 40
40 // static 41 // static
41 void Environment::InstantiateDefaultRunLoop() { 42 void Environment::InstantiateDefaultRunLoop() {
42 CHECK(!base::MessageLoop::current()); 43 CHECK(!base::MessageLoop::current());
43 // Not leaked: accessible from |base::MessageLoop::current()|. 44 // Not leaked: accessible from |base::MessageLoop::current()|.
44 base::MessageLoop* message_loop = new base::MessageLoop(); 45 base::MessageLoop* message_loop = new base::MessageLoop();
45 CHECK_EQ(message_loop, base::MessageLoop::current()); 46 CHECK_EQ(message_loop, base::MessageLoop::current());
46 } 47 }
47 48
48 // static 49 // static
49 void Environment::DestroyDefaultRunLoop() { 50 void Environment::DestroyDefaultRunLoop() {
50 CHECK(base::MessageLoop::current()); 51 CHECK(base::MessageLoop::current());
51 delete base::MessageLoop::current(); 52 delete base::MessageLoop::current();
52 CHECK(!base::MessageLoop::current()); 53 CHECK(!base::MessageLoop::current());
53 } 54 }
54 55
55 } // namespace mojo 56 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/application/lib/application_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698