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

Side by Side Diff: mojo/public/cpp/environment/lib/environment.cc

Issue 339403003: Mojo: Make GetDefault{AsyncWaiter,Logger} static methods of Environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 "mojo/public/cpp/environment/lib/default_logger_internal.h" 7 #include <stddef.h>
8
9 #include "mojo/public/c/environment/logger.h"
10 #include "mojo/public/cpp/environment/lib/default_async_waiter.h"
11 #include "mojo/public/cpp/environment/lib/default_logger.h"
8 #include "mojo/public/cpp/utility/run_loop.h" 12 #include "mojo/public/cpp/utility/run_loop.h"
9 13
10 namespace mojo { 14 namespace mojo {
11 15
16 namespace {
17
18 const MojoAsyncWaiter* g_default_async_waiter = NULL;
19 const MojoLogger* g_default_logger = NULL;
20
21 void Init(const MojoAsyncWaiter* default_async_waiter,
22 const MojoLogger* default_logger) {
23 g_default_async_waiter =
24 default_async_waiter ? default_async_waiter :
25 &internal::kDefaultAsyncWaiter;
26 g_default_logger = default_logger ? default_logger :
27 &internal::kDefaultLogger;
28
29 RunLoop::SetUp();
30 }
31
32 } // namespace
33
12 Environment::Environment() { 34 Environment::Environment() {
13 SetMinimumLogLevel(MOJO_LOG_LEVEL_INFO); 35 Init(NULL, NULL);
14 RunLoop::SetUp(); 36 }
37
38 Environment::Environment(const MojoAsyncWaiter* default_async_waiter,
39 const MojoLogger* default_logger) {
40 Init(default_async_waiter, default_logger);
15 } 41 }
16 42
17 Environment::~Environment() { 43 Environment::~Environment() {
18 RunLoop::TearDown(); 44 RunLoop::TearDown();
45
46 // TODO(vtl): Maybe we should allow nesting, and restore previous default
47 // async waiters and loggers?
19 } 48 }
20 49
21 // static 50 // static
22 void Environment::SetMinimumLogLevel(MojoLogLevel minimum_log_level) { 51 const MojoAsyncWaiter* Environment::GetDefaultAsyncWaiter() {
23 internal::SetMinimumLogLevel(minimum_log_level); 52 return g_default_async_waiter;
53 }
54
55 // static
56 const MojoLogger* Environment::GetDefaultLogger() {
57 return g_default_logger;
24 } 58 }
25 59
26 } // namespace mojo 60 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/environment/lib/default_logger_internal.h ('k') | mojo/public/cpp/environment/tests/async_waiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698