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

Side by Side Diff: components/device_event_log/device_event_log.cc

Issue 1140643002: Fix device_event_log component build, make NonThreadSafe (Take 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "components/device_event_log/device_event_log.h" 5 #include "components/device_event_log/device_event_log.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/thread_task_runner_handle.h"
10 #include "components/device_event_log/device_event_log_impl.h" 11 #include "components/device_event_log/device_event_log_impl.h"
11 12
12 namespace device_event_log { 13 namespace device_event_log {
13 14
14 namespace { 15 namespace {
15 16
16 const size_t kDefaultMaxEntries = 4000; 17 const size_t kDefaultMaxEntries = 4000;
17 18
18 const int kSlowMethodThresholdMs = 10; 19 const int kSlowMethodThresholdMs = 10;
19 const int kVerySlowMethodThresholdMs = 50; 20 const int kVerySlowMethodThresholdMs = 50;
20 21
21 DeviceEventLogImpl* g_device_event_log = NULL; 22 DeviceEventLogImpl* g_device_event_log = NULL;
22 23
23 } // namespace 24 } // namespace
24 25
25 const LogLevel kDefaultLogLevel = LOG_LEVEL_EVENT; 26 const LogLevel kDefaultLogLevel = LOG_LEVEL_EVENT;
26 27
27 void Initialize(size_t max_entries) { 28 void Initialize(size_t max_entries) {
28 CHECK(!g_device_event_log); 29 CHECK(!g_device_event_log);
29 if (max_entries == 0) 30 if (max_entries == 0)
30 max_entries = kDefaultMaxEntries; 31 max_entries = kDefaultMaxEntries;
31 g_device_event_log = new DeviceEventLogImpl(max_entries); 32 g_device_event_log =
33 new DeviceEventLogImpl(base::ThreadTaskRunnerHandle::Get(), max_entries);
34 }
35
36 bool IsInitialized() {
37 return !!g_device_event_log;
32 } 38 }
33 39
34 void Shutdown() { 40 void Shutdown() {
35 delete g_device_event_log; 41 delete g_device_event_log;
36 g_device_event_log = NULL; 42 g_device_event_log = NULL;
37 } 43 }
38 44
39 void AddEntry(const char* file, 45 void AddEntry(const char* file,
40 int line, 46 int line,
41 LogType type, 47 LogType type,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 level = LOG_LEVEL_ERROR; 116 level = LOG_LEVEL_ERROR;
111 DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_ 117 DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_
112 << ": " << timer_.Elapsed().InMilliseconds() 118 << ": " << timer_.Elapsed().InMilliseconds()
113 << "ms"; 119 << "ms";
114 } 120 }
115 } 121 }
116 122
117 } // namespace internal 123 } // namespace internal
118 124
119 } // namespace device_event_log 125 } // namespace device_event_log
OLDNEW
« no previous file with comments | « components/device_event_log/device_event_log.h ('k') | components/device_event_log/device_event_log_export.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698