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

Side by Side Diff: components/leveldb/env_mojo.cc

Issue 2137503002: Revert of Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/leveldb/env_mojo.h" 5 #include "components/leveldb/env_mojo.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/strings/string_util.h"
12 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
13 #include "third_party/leveldatabase/chromium_logger.h" 12 #include "third_party/leveldatabase/chromium_logger.h"
14 #include "third_party/leveldatabase/src/include/leveldb/status.h" 13 #include "third_party/leveldatabase/src/include/leveldb/status.h"
15 14
16 namespace leveldb { 15 namespace leveldb {
17 16
18 namespace { 17 namespace {
19 18
20 const base::FilePath::CharType table_extension[] = FILE_PATH_LITERAL(".ldb"); 19 const base::FilePath::CharType table_extension[] = FILE_PATH_LITERAL(".ldb");
21 20
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 MojoWritableFile(LevelDBMojoProxy::OpaqueDir* dir, 130 MojoWritableFile(LevelDBMojoProxy::OpaqueDir* dir,
132 const std::string& fname, 131 const std::string& fname,
133 base::File f, 132 base::File f,
134 scoped_refptr<LevelDBMojoProxy> thread) 133 scoped_refptr<LevelDBMojoProxy> thread)
135 : filename_(fname), 134 : filename_(fname),
136 file_(std::move(f)), 135 file_(std::move(f)),
137 file_type_(kOther), 136 file_type_(kOther),
138 dir_(dir), 137 dir_(dir),
139 thread_(thread) { 138 thread_(thread) {
140 base::FilePath path = base::FilePath::FromUTF8Unsafe(fname); 139 base::FilePath path = base::FilePath::FromUTF8Unsafe(fname);
141 if (base::StartsWith(path.BaseName().AsUTF8Unsafe(), "MANIFEST", 140 if (path.BaseName().AsUTF8Unsafe().find("MANIFEST") == 0)
142 base::CompareCase::SENSITIVE)) {
143 file_type_ = kManifest; 141 file_type_ = kManifest;
144 } else if (path.MatchesExtension(table_extension)) { 142 else if (path.MatchesExtension(table_extension))
145 file_type_ = kTable; 143 file_type_ = kTable;
146 }
147 parent_dir_ = 144 parent_dir_ =
148 base::FilePath::FromUTF8Unsafe(fname).DirName().AsUTF8Unsafe(); 145 base::FilePath::FromUTF8Unsafe(fname).DirName().AsUTF8Unsafe();
149 } 146 }
150 147
151 ~MojoWritableFile() override {} 148 ~MojoWritableFile() override {}
152 149
153 leveldb::Status Append(const leveldb::Slice& data) override { 150 leveldb::Status Append(const leveldb::Slice& data) override {
154 size_t bytes_written = file_.WriteAtCurrentPos( 151 size_t bytes_written = file_.WriteAtCurrentPos(
155 data.data(), static_cast<int>(data.size())); 152 data.data(), static_cast<int>(data.size()));
156 if (bytes_written != data.size()) { 153 if (bytes_written != data.size()) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 *result = NULL; 372 *result = NULL;
376 return MakeIOError(fname, "Unable to create log file", 373 return MakeIOError(fname, "Unable to create log file",
377 leveldb_env::kNewLogger, f->error_details()); 374 leveldb_env::kNewLogger, f->error_details());
378 } else { 375 } else {
379 *result = new leveldb::ChromiumLogger(f.release()); 376 *result = new leveldb::ChromiumLogger(f.release());
380 return Status::OK(); 377 return Status::OK();
381 } 378 }
382 } 379 }
383 380
384 } // namespace leveldb 381 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/devtools_http_handler/devtools_http_handler.cc ('k') | components/os_crypt/os_crypt_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698