OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "dbus/dbus_statistics.h" | 5 #include "dbus/dbus_statistics.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <set> | 8 #include <set> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 | 16 |
17 namespace dbus { | 17 namespace dbus { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Used to store dbus statistics sorted alphabetically by service, interface, | 21 // Used to store dbus statistics sorted alphabetically by service, interface, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 NOTREACHED(); | 101 NOTREACHED(); |
102 } | 102 } |
103 | 103 |
104 // Look up the Stat entry in |stats_|. If |add_stat| is true, add a new entry | 104 // Look up the Stat entry in |stats_|. If |add_stat| is true, add a new entry |
105 // if one does not already exist. | 105 // if one does not already exist. |
106 Stat* GetStat(const std::string& service, | 106 Stat* GetStat(const std::string& service, |
107 const std::string& interface, | 107 const std::string& interface, |
108 const std::string& method, | 108 const std::string& method, |
109 bool add_stat) { | 109 bool add_stat) { |
110 DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); | 110 DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); |
111 scoped_ptr<Stat> stat(new Stat(service, interface, method)); | 111 std::unique_ptr<Stat> stat(new Stat(service, interface, method)); |
112 StatSet::iterator found = stats_.find(stat.get()); | 112 StatSet::iterator found = stats_.find(stat.get()); |
113 if (found != stats_.end()) | 113 if (found != stats_.end()) |
114 return *found; | 114 return *found; |
115 if (!add_stat) | 115 if (!add_stat) |
116 return NULL; | 116 return NULL; |
117 found = stats_.insert(stat.release()).first; | 117 found = stats_.insert(stat.release()).first; |
118 return *found; | 118 return *found; |
119 } | 119 } |
120 | 120 |
121 StatSet& stats() { return stats_; } | 121 StatSet& stats() { return stats_; } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 *sent = stat->sent_method_calls; | 275 *sent = stat->sent_method_calls; |
276 *received = stat->received_signals; | 276 *received = stat->received_signals; |
277 *blocking = stat->sent_blocking_method_calls; | 277 *blocking = stat->sent_blocking_method_calls; |
278 return true; | 278 return true; |
279 } | 279 } |
280 | 280 |
281 } // namespace testing | 281 } // namespace testing |
282 | 282 |
283 } // namespace statistics | 283 } // namespace statistics |
284 } // namespace dbus | 284 } // namespace dbus |
OLD | NEW |