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

Side by Side Diff: extensions/common/extension_icon_set.cc

Issue 2626923002: Make ExtensionIconSet::ContainsPath use StringPiece. (Closed)
Patch Set: Created 3 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 "extensions/common/extension_icon_set.h" 5 #include "extensions/common/extension_icon_set.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ++iter) { 46 ++iter) {
47 if (iter->first >= size) { 47 if (iter->first >= size) {
48 result = iter; 48 result = iter;
49 break; 49 break;
50 } 50 }
51 } 51 }
52 return result == map_.end() ? base::EmptyString() : result->second; 52 return result == map_.end() ? base::EmptyString() : result->second;
53 } 53 }
54 } 54 }
55 55
56 bool ExtensionIconSet::ContainsPath(const std::string& path) const { 56 bool ExtensionIconSet::ContainsPath(base::StringPiece path) const {
57 return GetIconSizeFromPath(path) != 0; 57 return GetIconSizeFromPath(path) != 0;
58 } 58 }
59 59
60 int ExtensionIconSet::GetIconSizeFromPath(const std::string& path) const { 60 int ExtensionIconSet::GetIconSizeFromPath(base::StringPiece path) const {
61 if (path.empty()) 61 if (path.empty())
62 return 0; 62 return 0;
63 63
64 DCHECK_NE(path[0], '/') << 64 DCHECK_NE(path[0], '/') <<
65 "ExtensionIconSet stores icon paths without leading slash."; 65 "ExtensionIconSet stores icon paths without leading slash.";
66 66
67 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end(); 67 for (IconMap::const_iterator iter = map_.begin(); iter != map_.end();
68 ++iter) { 68 ++iter) {
69 if (iter->second == path) 69 if (iter->second == path)
70 return iter->first; 70 return iter->first;
71 } 71 }
72 72
73 return 0; 73 return 0;
74 } 74 }
75 75
76 void ExtensionIconSet::GetPaths(std::set<base::FilePath>* paths) const { 76 void ExtensionIconSet::GetPaths(std::set<base::FilePath>* paths) const {
77 CHECK(paths); 77 CHECK(paths);
78 for (auto iter : map()) 78 for (auto iter : map())
79 paths->insert(base::FilePath::FromUTF8Unsafe(iter.second)); 79 paths->insert(base::FilePath::FromUTF8Unsafe(iter.second));
80 } 80 }
OLDNEW
« no previous file with comments | « extensions/common/extension_icon_set.h ('k') | extensions/common/extension_icon_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698