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

Side by Side Diff: base/trace_event/trace_log.cc

Issue 2830093003: Replace uses of hash_map in //base (Closed)
Patch Set: WebKit callers Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 // Check if the thread name has been set or changed since the previous 1222 // Check if the thread name has been set or changed since the previous
1223 // call (if any), but don't bother if the new name is empty. Note this will 1223 // call (if any), but don't bother if the new name is empty. Note this will
1224 // not detect a thread name change within the same char* buffer address: we 1224 // not detect a thread name change within the same char* buffer address: we
1225 // favor common case performance over corner case correctness. 1225 // favor common case performance over corner case correctness.
1226 static auto* current_thread_name = new ThreadLocalPointer<const char>(); 1226 static auto* current_thread_name = new ThreadLocalPointer<const char>();
1227 if (new_name != current_thread_name->Get() && new_name && *new_name) { 1227 if (new_name != current_thread_name->Get() && new_name && *new_name) {
1228 current_thread_name->Set(new_name); 1228 current_thread_name->Set(new_name);
1229 1229
1230 AutoLock thread_info_lock(thread_info_lock_); 1230 AutoLock thread_info_lock(thread_info_lock_);
1231 1231
1232 hash_map<int, std::string>::iterator existing_name = 1232 auto existing_name = thread_names_.find(thread_id);
1233 thread_names_.find(thread_id);
1234 if (existing_name == thread_names_.end()) { 1233 if (existing_name == thread_names_.end()) {
1235 // This is a new thread id, and a new name. 1234 // This is a new thread id, and a new name.
1236 thread_names_[thread_id] = new_name; 1235 thread_names_[thread_id] = new_name;
1237 } else { 1236 } else {
1238 // This is a thread id that we've seen before, but potentially with a 1237 // This is a thread id that we've seen before, but potentially with a
1239 // new name. 1238 // new name.
1240 std::vector<StringPiece> existing_names = base::SplitStringPiece( 1239 std::vector<StringPiece> existing_names = base::SplitStringPiece(
1241 existing_name->second, ",", base::KEEP_WHITESPACE, 1240 existing_name->second, ",", base::KEEP_WHITESPACE,
1242 base::SPLIT_WANT_NONEMPTY); 1241 base::SPLIT_WANT_NONEMPTY);
1243 bool found = std::find(existing_names.begin(), existing_names.end(), 1242 bool found = std::find(existing_names.begin(), existing_names.end(),
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 } 1734 }
1736 1735
1737 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1736 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1738 if (*category_group_enabled_) { 1737 if (*category_group_enabled_) {
1739 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1738 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1740 event_handle_); 1739 event_handle_);
1741 } 1740 }
1742 } 1741 }
1743 1742
1744 } // namespace trace_event_internal 1743 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698