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

Side by Side Diff: base/path_service.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/path_service.h" 5 #include "base/path_service.h"
6 6
7 #ifdef OS_WIN 7 #ifdef OS_WIN
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #endif 11 #endif
12 12
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/hash_tables.h" 15 #include "base/hash_tables.h"
16 #include "base/lazy_instance.h"
16 #include "base/lock.h" 17 #include "base/lock.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/singleton.h"
19 19
20 namespace base { 20 namespace base {
21 bool PathProvider(int key, FilePath* result); 21 bool PathProvider(int key, FilePath* result);
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 bool PathProviderWin(int key, FilePath* result); 23 bool PathProviderWin(int key, FilePath* result);
24 #elif defined(OS_MACOSX) 24 #elif defined(OS_MACOSX)
25 bool PathProviderMac(int key, FilePath* result); 25 bool PathProviderMac(int key, FilePath* result);
26 #elif defined(OS_POSIX) 26 #elif defined(OS_POSIX)
27 bool PathProviderPosix(int key, FilePath* result); 27 bool PathProviderPosix(int key, FilePath* result);
28 #endif 28 #endif
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Provider* p = providers; 111 Provider* p = providers;
112 while (p) { 112 while (p) {
113 Provider* next = p->next; 113 Provider* next = p->next;
114 if (!p->is_static) 114 if (!p->is_static)
115 delete p; 115 delete p;
116 p = next; 116 p = next;
117 } 117 }
118 } 118 }
119 }; 119 };
120 120
121 static base::LazyInstance<PathData> g_path_data(base::LINKER_INITIALIZED);
Evan Martin 2010/12/13 17:38:30 *
122
121 static PathData* GetPathData() { 123 static PathData* GetPathData() {
122 return Singleton<PathData>::get(); 124 return g_path_data.Pointer();
123 } 125 }
124 126
125 } // namespace 127 } // namespace
126 128
127 129
128 // static 130 // static
129 bool PathService::GetFromCache(int key, FilePath* result) { 131 bool PathService::GetFromCache(int key, FilePath* result) {
130 PathData* path_data = GetPathData(); 132 PathData* path_data = GetPathData();
131 AutoLock scoped_lock(path_data->lock); 133 AutoLock scoped_lock(path_data->lock);
132 134
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 p = new Provider; 259 p = new Provider;
258 p->is_static = false; 260 p->is_static = false;
259 p->func = func; 261 p->func = func;
260 p->next = path_data->providers; 262 p->next = path_data->providers;
261 #ifndef NDEBUG 263 #ifndef NDEBUG
262 p->key_start = key_start; 264 p->key_start = key_start;
263 p->key_end = key_end; 265 p->key_end = key_end;
264 #endif 266 #endif
265 path_data->providers = p; 267 path_data->providers = p;
266 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698