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

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store.cc

Issue 311263014: IndexedDB: Fix trivial cpplint.py errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/indexed_db/indexed_db_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } while (0) 155 } while (0)
156 156
157 #define INTERNAL_READ_ERROR(location) REPORT_ERROR("Read", location) 157 #define INTERNAL_READ_ERROR(location) REPORT_ERROR("Read", location)
158 #define INTERNAL_CONSISTENCY_ERROR(location) \ 158 #define INTERNAL_CONSISTENCY_ERROR(location) \
159 REPORT_ERROR("Consistency", location) 159 REPORT_ERROR("Consistency", location)
160 #define INTERNAL_WRITE_ERROR(location) REPORT_ERROR("Write", location) 160 #define INTERNAL_WRITE_ERROR(location) REPORT_ERROR("Write", location)
161 161
162 // Use to signal conditions that usually indicate developer error, but 162 // Use to signal conditions that usually indicate developer error, but
163 // could be caused by data corruption. A macro is used instead of an 163 // could be caused by data corruption. A macro is used instead of an
164 // inline function so that the assert and log report the line number. 164 // inline function so that the assert and log report the line number.
165 // TODO: Improve test coverage so that all error conditions are "tested" and 165 // TODO(cmumford): Improve test coverage so that all error conditions are
166 // then delete this macro. 166 // "tested" and then delete this macro.
167 #define REPORT_ERROR_UNTESTED(type, location) \ 167 #define REPORT_ERROR_UNTESTED(type, location) \
168 do { \ 168 do { \
169 LOG(ERROR) << "IndexedDB " type " Error: " #location; \ 169 LOG(ERROR) << "IndexedDB " type " Error: " #location; \
170 NOTREACHED(); \ 170 NOTREACHED(); \
171 RecordInternalError(type, location); \ 171 RecordInternalError(type, location); \
172 } while (0) 172 } while (0)
173 173
174 #define INTERNAL_READ_ERROR_UNTESTED(location) \ 174 #define INTERNAL_READ_ERROR_UNTESTED(location) \
175 REPORT_ERROR_UNTESTED("Read", location) 175 REPORT_ERROR_UNTESTED("Read", location)
176 #define INTERNAL_CONSISTENCY_ERROR_UNTESTED(location) \ 176 #define INTERNAL_CONSISTENCY_ERROR_UNTESTED(location) \
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 const GURL& origin_url) { 857 const GURL& origin_url) {
858 const base::FilePath file_path = 858 const base::FilePath file_path =
859 path_base.Append(ComputeFileName(origin_url)); 859 path_base.Append(ComputeFileName(origin_url));
860 DefaultLevelDBFactory leveldb_factory; 860 DefaultLevelDBFactory leveldb_factory;
861 return leveldb_factory.DestroyLevelDB(file_path); 861 return leveldb_factory.DestroyLevelDB(file_path);
862 } 862 }
863 863
864 bool IndexedDBBackingStore::ReadCorruptionInfo(const base::FilePath& path_base, 864 bool IndexedDBBackingStore::ReadCorruptionInfo(const base::FilePath& path_base,
865 const GURL& origin_url, 865 const GURL& origin_url,
866 std::string& message) { 866 std::string& message) {
867
868 const base::FilePath info_path = 867 const base::FilePath info_path =
869 path_base.Append(ComputeCorruptionFileName(origin_url)); 868 path_base.Append(ComputeCorruptionFileName(origin_url));
870 869
871 if (IsPathTooLong(info_path)) 870 if (IsPathTooLong(info_path))
872 return false; 871 return false;
873 872
874 const int64 max_json_len = 4096; 873 const int64 max_json_len = 4096;
875 int64 file_size(0); 874 int64 file_size(0);
876 if (!GetFileSize(info_path, &file_size) || file_size > max_json_len) 875 if (!GetFileSize(info_path, &file_size) || file_size > max_json_len)
877 return false; 876 return false;
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 : chained_blob_writer_(chained_blob_writer), 2240 : chained_blob_writer_(chained_blob_writer),
2242 task_runner_(task_runner), 2241 task_runner_(task_runner),
2243 bytes_written_(-1) {} 2242 bytes_written_(-1) {}
2244 2243
2245 void Run(base::File::Error rv, 2244 void Run(base::File::Error rv,
2246 int64 bytes, 2245 int64 bytes,
2247 FileWriterDelegate::WriteProgressStatus write_status) { 2246 FileWriterDelegate::WriteProgressStatus write_status) {
2248 if (write_status == FileWriterDelegate::SUCCESS_IO_PENDING) 2247 if (write_status == FileWriterDelegate::SUCCESS_IO_PENDING)
2249 return; // We don't care about progress events. 2248 return; // We don't care about progress events.
2250 if (rv == base::File::FILE_OK) { 2249 if (rv == base::File::FILE_OK) {
2251 DCHECK(bytes >= 0); 2250 DCHECK_GE(bytes, 0);
2252 DCHECK(write_status == FileWriterDelegate::SUCCESS_COMPLETED); 2251 DCHECK_EQ(write_status, FileWriterDelegate::SUCCESS_COMPLETED);
2253 bytes_written_ = bytes; 2252 bytes_written_ = bytes;
2254 } else { 2253 } else {
2255 DCHECK(write_status == FileWriterDelegate::ERROR_WRITE_STARTED || 2254 DCHECK(write_status == FileWriterDelegate::ERROR_WRITE_STARTED ||
2256 write_status == FileWriterDelegate::ERROR_WRITE_NOT_STARTED); 2255 write_status == FileWriterDelegate::ERROR_WRITE_NOT_STARTED);
2257 } 2256 }
2258 task_runner_->PostTask( 2257 task_runner_->PostTask(
2259 FROM_HERE, 2258 FROM_HERE,
2260 base::Bind(&LocalWriteClosure::callBlobCallbackOnIDBTaskRunner, 2259 base::Bind(&LocalWriteClosure::callBlobCallbackOnIDBTaskRunner,
2261 this, 2260 this,
2262 write_status == FileWriterDelegate::SUCCESS_COMPLETED)); 2261 write_status == FileWriterDelegate::SUCCESS_COMPLETED));
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4178 const GURL& url, 4177 const GURL& url,
4179 int64_t key) 4178 int64_t key)
4180 : is_file_(false), url_(url), key_(key) {} 4179 : is_file_(false), url_(url), key_(key) {}
4181 4180
4182 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor( 4181 IndexedDBBackingStore::Transaction::WriteDescriptor::WriteDescriptor(
4183 const FilePath& file_path, 4182 const FilePath& file_path,
4184 int64_t key) 4183 int64_t key)
4185 : is_file_(true), file_path_(file_path), key_(key) {} 4184 : is_file_(true), file_path_(file_path), key_(key) {}
4186 4185
4187 } // namespace content 4186 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.h ('k') | content/browser/indexed_db/indexed_db_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698