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

Side by Side Diff: storage/common/fileapi/file_system_util.cc

Issue 2127373006: Use base::StartWith() in more places when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 4 years, 5 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 (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 "storage/common/fileapi/file_system_util.h" 5 #include "storage/common/fileapi/file_system_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 for (size_t i = 0; i < num_separators; ++i) { 131 for (size_t i = 0; i < num_separators; ++i) {
132 std::replace(normalized_path.begin(), normalized_path.end(), 132 std::replace(normalized_path.begin(), normalized_path.end(),
133 base::FilePath::kSeparators[i], kSeparator); 133 base::FilePath::kSeparators[i], kSeparator);
134 } 134 }
135 135
136 return (IsAbsolute(normalized_path)) ? 136 return (IsAbsolute(normalized_path)) ?
137 normalized_path : base::FilePath::StringType(kRoot) + normalized_path; 137 normalized_path : base::FilePath::StringType(kRoot) + normalized_path;
138 } 138 }
139 139
140 bool VirtualPath::IsAbsolute(const base::FilePath::StringType& path) { 140 bool VirtualPath::IsAbsolute(const base::FilePath::StringType& path) {
141 return path.find(kRoot) == 0; 141 return base::StartsWith(path, kRoot, base::CompareCase::SENSITIVE);
142 } 142 }
143 143
144 bool VirtualPath::IsRootPath(const base::FilePath& path) { 144 bool VirtualPath::IsRootPath(const base::FilePath& path) {
145 std::vector<base::FilePath::StringType> components; 145 std::vector<base::FilePath::StringType> components;
146 VirtualPath::GetComponents(path, &components); 146 VirtualPath::GetComponents(path, &components);
147 return (path.empty() || components.empty() || 147 return (path.empty() || components.empty() ||
148 (components.size() == 1 && 148 (components.size() == 1 &&
149 components[0] == VirtualPath::kRoot)); 149 components[0] == VirtualPath::kRoot));
150 } 150 }
151 151
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 return base::File::FILE_ERROR_ABORT; 501 return base::File::FILE_ERROR_ABORT;
502 case net::ERR_ADDRESS_INVALID: 502 case net::ERR_ADDRESS_INVALID:
503 case net::ERR_INVALID_URL: 503 case net::ERR_INVALID_URL:
504 return base::File::FILE_ERROR_INVALID_URL; 504 return base::File::FILE_ERROR_INVALID_URL;
505 default: 505 default:
506 return base::File::FILE_ERROR_FAILED; 506 return base::File::FILE_ERROR_FAILED;
507 } 507 }
508 } 508 }
509 509
510 } // namespace storage 510 } // namespace storage
OLDNEW
« no previous file with comments | « media/cast/sender/external_video_encoder.cc ('k') | tools/android/forwarder2/host_forwarder_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698