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

Side by Side Diff: chrome/browser/extensions/chrome_component_extension_resource_manager.cc

Issue 830833002: Makes GetComponentExtensionResourceManager() thread-safe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/chrome_component_extension_resource_manager. h" 5 #include "chrome/browser/extensions/chrome_component_extension_resource_manager. h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "grit/chrome_unscaled_resources.h" 10 #include "grit/chrome_unscaled_resources.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 keyboard_resource_size); 58 keyboard_resource_size);
59 #endif 59 #endif
60 } 60 }
61 61
62 ChromeComponentExtensionResourceManager:: 62 ChromeComponentExtensionResourceManager::
63 ~ChromeComponentExtensionResourceManager() {} 63 ~ChromeComponentExtensionResourceManager() {}
64 64
65 bool ChromeComponentExtensionResourceManager::IsComponentExtensionResource( 65 bool ChromeComponentExtensionResourceManager::IsComponentExtensionResource(
66 const base::FilePath& extension_path, 66 const base::FilePath& extension_path,
67 const base::FilePath& resource_path, 67 const base::FilePath& resource_path,
68 int* resource_id) { 68 int* resource_id) const {
69 base::FilePath directory_path = extension_path; 69 base::FilePath directory_path = extension_path;
70 base::FilePath resources_dir; 70 base::FilePath resources_dir;
71 base::FilePath relative_path; 71 base::FilePath relative_path;
72 if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) || 72 if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) ||
73 !resources_dir.AppendRelativePath(directory_path, &relative_path)) { 73 !resources_dir.AppendRelativePath(directory_path, &relative_path)) {
74 return false; 74 return false;
75 } 75 }
76 relative_path = relative_path.Append(resource_path); 76 relative_path = relative_path.Append(resource_path);
77 relative_path = relative_path.NormalizePathSeparators(); 77 relative_path = relative_path.NormalizePathSeparators();
78 78
(...skipping 13 matching lines...) Expand all
92 entries[i].name); 92 entries[i].name);
93 resource_path = resource_path.NormalizePathSeparators(); 93 resource_path = resource_path.NormalizePathSeparators();
94 94
95 DCHECK(path_to_resource_id_.find(resource_path) == 95 DCHECK(path_to_resource_id_.find(resource_path) ==
96 path_to_resource_id_.end()); 96 path_to_resource_id_.end());
97 path_to_resource_id_[resource_path] = entries[i].value; 97 path_to_resource_id_[resource_path] = entries[i].value;
98 } 98 }
99 } 99 }
100 100
101 } // namespace extensions 101 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698