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

Side by Side Diff: base/threading/thread_id_name_manager.cc

Issue 1124563003: Revert some other possible suspects of a 0.43% size increase of setup.exe: https://build.chromium.o… (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
« no previous file with comments | « base/threading/thread_id_name_manager.h ('k') | base/threading/watchdog.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 (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 "base/threading/thread_id_name_manager.h" 5 #include "base/threading/thread_id_name_manager.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 void ThreadIdNameManager::RegisterThread(PlatformThreadHandle::Handle handle, 43 void ThreadIdNameManager::RegisterThread(PlatformThreadHandle::Handle handle,
44 PlatformThreadId id) { 44 PlatformThreadId id) {
45 AutoLock locked(lock_); 45 AutoLock locked(lock_);
46 thread_id_to_handle_[id] = handle; 46 thread_id_to_handle_[id] = handle;
47 thread_handle_to_interned_name_[handle] = 47 thread_handle_to_interned_name_[handle] =
48 name_to_interned_name_[kDefaultName]; 48 name_to_interned_name_[kDefaultName];
49 } 49 }
50 50
51 void ThreadIdNameManager::SetName(PlatformThreadId id, 51 void ThreadIdNameManager::SetName(PlatformThreadId id, const char* name) {
52 const std::string& name) { 52 std::string str_name(name);
53
53 AutoLock locked(lock_); 54 AutoLock locked(lock_);
54 NameToInternedNameMap::iterator iter = name_to_interned_name_.find(name); 55 NameToInternedNameMap::iterator iter = name_to_interned_name_.find(str_name);
55 std::string* leaked_str = NULL; 56 std::string* leaked_str = NULL;
56 if (iter != name_to_interned_name_.end()) { 57 if (iter != name_to_interned_name_.end()) {
57 leaked_str = iter->second; 58 leaked_str = iter->second;
58 } else { 59 } else {
59 leaked_str = new std::string(name); 60 leaked_str = new std::string(str_name);
60 name_to_interned_name_[name] = leaked_str; 61 name_to_interned_name_[str_name] = leaked_str;
61 } 62 }
62 63
63 ThreadIdToHandleMap::iterator id_to_handle_iter = 64 ThreadIdToHandleMap::iterator id_to_handle_iter =
64 thread_id_to_handle_.find(id); 65 thread_id_to_handle_.find(id);
65 66
66 // The main thread of a process will not be created as a Thread object which 67 // The main thread of a process will not be created as a Thread object which
67 // means there is no PlatformThreadHandler registered. 68 // means there is no PlatformThreadHandler registered.
68 if (id_to_handle_iter == thread_id_to_handle_.end()) { 69 if (id_to_handle_iter == thread_id_to_handle_.end()) {
69 main_process_name_ = leaked_str; 70 main_process_name_ = leaked_str;
70 main_process_id_ = id; 71 main_process_id_ = id;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 DCHECK((id_to_handle_iter!= thread_id_to_handle_.end())); 104 DCHECK((id_to_handle_iter!= thread_id_to_handle_.end()));
104 // The given |id| may have been re-used by the system. Make sure the 105 // The given |id| may have been re-used by the system. Make sure the
105 // mapping points to the provided |handle| before removal. 106 // mapping points to the provided |handle| before removal.
106 if (id_to_handle_iter->second != handle) 107 if (id_to_handle_iter->second != handle)
107 return; 108 return;
108 109
109 thread_id_to_handle_.erase(id_to_handle_iter); 110 thread_id_to_handle_.erase(id_to_handle_iter);
110 } 111 }
111 112
112 } // namespace base 113 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread_id_name_manager.h ('k') | base/threading/watchdog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698