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

Side by Side Diff: base/path_service.cc

Issue 7184032: Upstream android file related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove android specific shmem method Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.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_ANDROID)
27 bool PathProviderAndroid(int key, FilePath* result);
26 #elif defined(OS_POSIX) 28 #elif defined(OS_POSIX)
27 bool PathProviderPosix(int key, FilePath* result); 29 bool PathProviderPosix(int key, FilePath* result);
28 #endif 30 #endif
29 } 31 }
30 32
31 namespace { 33 namespace {
32 34
33 typedef base::hash_map<int, FilePath> PathMap; 35 typedef base::hash_map<int, FilePath> PathMap;
34 36
35 // We keep a linked list of providers. In a debug build we ensure that no two 37 // We keep a linked list of providers. In a debug build we ensure that no two
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 base::PathProviderMac, 73 base::PathProviderMac,
72 &base_provider, 74 &base_provider,
73 #ifndef NDEBUG 75 #ifndef NDEBUG
74 base::PATH_MAC_START, 76 base::PATH_MAC_START,
75 base::PATH_MAC_END, 77 base::PATH_MAC_END,
76 #endif 78 #endif
77 true 79 true
78 }; 80 };
79 #endif 81 #endif
80 82
81 #if defined(OS_POSIX) && !defined(OS_MACOSX) 83 #if defined(OS_ANDROID)
84 static Provider base_provider_android = {
85 base::PathProviderAndroid,
86 &base_provider,
87 #ifndef NDEBUG
88 0,
89 0,
90 #endif
91 true
92 };
93 #endif
94
95 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
82 static Provider base_provider_posix = { 96 static Provider base_provider_posix = {
83 base::PathProviderPosix, 97 base::PathProviderPosix,
84 &base_provider, 98 &base_provider,
85 #ifndef NDEBUG 99 #ifndef NDEBUG
86 0, 100 0,
87 0, 101 0,
88 #endif 102 #endif
89 true 103 true
90 }; 104 };
91 #endif 105 #endif
92 106
93 107
94 struct PathData { 108 struct PathData {
95 base::Lock lock; 109 base::Lock lock;
96 PathMap cache; // Cache mappings from path key to path value. 110 PathMap cache; // Cache mappings from path key to path value.
97 PathMap overrides; // Track path overrides. 111 PathMap overrides; // Track path overrides.
98 Provider* providers; // Linked list of path service providers. 112 Provider* providers; // Linked list of path service providers.
99 113
100 PathData() { 114 PathData() {
101 #if defined(OS_WIN) 115 #if defined(OS_WIN)
102 providers = &base_provider_win; 116 providers = &base_provider_win;
103 #elif defined(OS_MACOSX) 117 #elif defined(OS_MACOSX)
104 providers = &base_provider_mac; 118 providers = &base_provider_mac;
119 #elif defined(OS_ANDROID)
120 providers = &base_provider_android;
105 #elif defined(OS_POSIX) 121 #elif defined(OS_POSIX)
106 providers = &base_provider_posix; 122 providers = &base_provider_posix;
107 #endif 123 #endif
108 } 124 }
109 125
110 ~PathData() { 126 ~PathData() {
111 Provider* p = providers; 127 Provider* p = providers;
112 while (p) { 128 while (p) {
113 Provider* next = p->next; 129 Provider* next = p->next;
114 if (!p->is_static) 130 if (!p->is_static)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 p = new Provider; 275 p = new Provider;
260 p->is_static = false; 276 p->is_static = false;
261 p->func = func; 277 p->func = func;
262 p->next = path_data->providers; 278 p->next = path_data->providers;
263 #ifndef NDEBUG 279 #ifndef NDEBUG
264 p->key_start = key_start; 280 p->key_start = key_start;
265 p->key_end = key_end; 281 p->key_end = key_end;
266 #endif 282 #endif
267 path_data->providers = p; 283 path_data->providers = p;
268 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698