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

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

Issue 602883003: Replacing the OVERRIDE with override and FINAL with final in content/browser/indexed_db (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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) 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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 DCHECK_GE(*max_object_store_id, 0); 482 DCHECK_GE(*max_object_store_id, 0);
483 return s; 483 return s;
484 } 484 }
485 485
486 class DefaultLevelDBFactory : public LevelDBFactory { 486 class DefaultLevelDBFactory : public LevelDBFactory {
487 public: 487 public:
488 DefaultLevelDBFactory() {} 488 DefaultLevelDBFactory() {}
489 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, 489 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name,
490 const LevelDBComparator* comparator, 490 const LevelDBComparator* comparator,
491 scoped_ptr<LevelDBDatabase>* db, 491 scoped_ptr<LevelDBDatabase>* db,
492 bool* is_disk_full) OVERRIDE { 492 bool* is_disk_full) override {
493 return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full); 493 return LevelDBDatabase::Open(file_name, comparator, db, is_disk_full);
494 } 494 }
495 virtual leveldb::Status DestroyLevelDB(const base::FilePath& file_name) 495 virtual leveldb::Status DestroyLevelDB(const base::FilePath& file_name)
496 OVERRIDE { 496 override {
497 return LevelDBDatabase::Destroy(file_name); 497 return LevelDBDatabase::Destroy(file_name);
498 } 498 }
499 499
500 private: 500 private:
501 DISALLOW_COPY_AND_ASSIGN(DefaultLevelDBFactory); 501 DISALLOW_COPY_AND_ASSIGN(DefaultLevelDBFactory);
502 }; 502 };
503 503
504 static bool GetBlobKeyGeneratorCurrentNumber( 504 static bool GetBlobKeyGeneratorCurrentNumber(
505 LevelDBTransaction* leveldb_transaction, 505 LevelDBTransaction* leveldb_transaction,
506 int64 database_id, 506 int64 database_id,
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 database_id_(database_id), 2200 database_id_(database_id),
2201 backing_store_(backing_store), 2201 backing_store_(backing_store),
2202 callback_(callback), 2202 callback_(callback),
2203 aborted_(false) { 2203 aborted_(false) {
2204 blobs_.swap(*blobs); 2204 blobs_.swap(*blobs);
2205 iter_ = blobs_.begin(); 2205 iter_ = blobs_.begin();
2206 backing_store->task_runner()->PostTask( 2206 backing_store->task_runner()->PostTask(
2207 FROM_HERE, base::Bind(&ChainedBlobWriterImpl::WriteNextFile, this)); 2207 FROM_HERE, base::Bind(&ChainedBlobWriterImpl::WriteNextFile, this));
2208 } 2208 }
2209 2209
2210 virtual void set_delegate(scoped_ptr<FileWriterDelegate> delegate) OVERRIDE { 2210 virtual void set_delegate(scoped_ptr<FileWriterDelegate> delegate) override {
2211 delegate_.reset(delegate.release()); 2211 delegate_.reset(delegate.release());
2212 } 2212 }
2213 2213
2214 virtual void ReportWriteCompletion(bool succeeded, 2214 virtual void ReportWriteCompletion(bool succeeded,
2215 int64 bytes_written) OVERRIDE { 2215 int64 bytes_written) override {
2216 DCHECK(waiting_for_callback_); 2216 DCHECK(waiting_for_callback_);
2217 DCHECK(!succeeded || bytes_written >= 0); 2217 DCHECK(!succeeded || bytes_written >= 0);
2218 waiting_for_callback_ = false; 2218 waiting_for_callback_ = false;
2219 if (delegate_.get()) // Only present for Blob, not File. 2219 if (delegate_.get()) // Only present for Blob, not File.
2220 content::BrowserThread::DeleteSoon( 2220 content::BrowserThread::DeleteSoon(
2221 content::BrowserThread::IO, FROM_HERE, delegate_.release()); 2221 content::BrowserThread::IO, FROM_HERE, delegate_.release());
2222 if (aborted_) { 2222 if (aborted_) {
2223 self_ref_ = NULL; 2223 self_ref_ = NULL;
2224 return; 2224 return;
2225 } 2225 }
2226 if (iter_->size() != -1 && iter_->size() != bytes_written) 2226 if (iter_->size() != -1 && iter_->size() != bytes_written)
2227 succeeded = false; 2227 succeeded = false;
2228 if (succeeded) { 2228 if (succeeded) {
2229 ++iter_; 2229 ++iter_;
2230 WriteNextFile(); 2230 WriteNextFile();
2231 } else { 2231 } else {
2232 callback_->Run(false); 2232 callback_->Run(false);
2233 } 2233 }
2234 } 2234 }
2235 2235
2236 virtual void Abort() OVERRIDE { 2236 virtual void Abort() override {
2237 if (!waiting_for_callback_) 2237 if (!waiting_for_callback_)
2238 return; 2238 return;
2239 self_ref_ = this; 2239 self_ref_ = this;
2240 aborted_ = true; 2240 aborted_ = true;
2241 } 2241 }
2242 2242
2243 private: 2243 private:
2244 virtual ~ChainedBlobWriterImpl() {} 2244 virtual ~ChainedBlobWriterImpl() {}
2245 2245
2246 void WriteNextFile() { 2246 void WriteNextFile() {
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 ObjectStoreKeyCursorImpl( 3245 ObjectStoreKeyCursorImpl(
3246 scoped_refptr<IndexedDBBackingStore> backing_store, 3246 scoped_refptr<IndexedDBBackingStore> backing_store,
3247 IndexedDBBackingStore::Transaction* transaction, 3247 IndexedDBBackingStore::Transaction* transaction,
3248 int64 database_id, 3248 int64 database_id,
3249 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3249 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3250 : IndexedDBBackingStore::Cursor(backing_store, 3250 : IndexedDBBackingStore::Cursor(backing_store,
3251 transaction, 3251 transaction,
3252 database_id, 3252 database_id,
3253 cursor_options) {} 3253 cursor_options) {}
3254 3254
3255 virtual Cursor* Clone() OVERRIDE { 3255 virtual Cursor* Clone() override {
3256 return new ObjectStoreKeyCursorImpl(this); 3256 return new ObjectStoreKeyCursorImpl(this);
3257 } 3257 }
3258 3258
3259 // IndexedDBBackingStore::Cursor 3259 // IndexedDBBackingStore::Cursor
3260 virtual IndexedDBValue* value() OVERRIDE { 3260 virtual IndexedDBValue* value() override {
3261 NOTREACHED(); 3261 NOTREACHED();
3262 return NULL; 3262 return NULL;
3263 } 3263 }
3264 virtual bool LoadCurrentRow() OVERRIDE; 3264 virtual bool LoadCurrentRow() override;
3265 3265
3266 protected: 3266 protected:
3267 virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE { 3267 virtual std::string EncodeKey(const IndexedDBKey& key) override {
3268 return ObjectStoreDataKey::Encode( 3268 return ObjectStoreDataKey::Encode(
3269 cursor_options_.database_id, cursor_options_.object_store_id, key); 3269 cursor_options_.database_id, cursor_options_.object_store_id, key);
3270 } 3270 }
3271 virtual std::string EncodeKey(const IndexedDBKey& key, 3271 virtual std::string EncodeKey(const IndexedDBKey& key,
3272 const IndexedDBKey& primary_key) OVERRIDE { 3272 const IndexedDBKey& primary_key) override {
3273 NOTREACHED(); 3273 NOTREACHED();
3274 return std::string(); 3274 return std::string();
3275 } 3275 }
3276 3276
3277 private: 3277 private:
3278 explicit ObjectStoreKeyCursorImpl(const ObjectStoreKeyCursorImpl* other) 3278 explicit ObjectStoreKeyCursorImpl(const ObjectStoreKeyCursorImpl* other)
3279 : IndexedDBBackingStore::Cursor(other) {} 3279 : IndexedDBBackingStore::Cursor(other) {}
3280 3280
3281 DISALLOW_COPY_AND_ASSIGN(ObjectStoreKeyCursorImpl); 3281 DISALLOW_COPY_AND_ASSIGN(ObjectStoreKeyCursorImpl);
3282 }; 3282 };
(...skipping 28 matching lines...) Expand all
3311 ObjectStoreCursorImpl( 3311 ObjectStoreCursorImpl(
3312 scoped_refptr<IndexedDBBackingStore> backing_store, 3312 scoped_refptr<IndexedDBBackingStore> backing_store,
3313 IndexedDBBackingStore::Transaction* transaction, 3313 IndexedDBBackingStore::Transaction* transaction,
3314 int64 database_id, 3314 int64 database_id,
3315 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3315 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3316 : IndexedDBBackingStore::Cursor(backing_store, 3316 : IndexedDBBackingStore::Cursor(backing_store,
3317 transaction, 3317 transaction,
3318 database_id, 3318 database_id,
3319 cursor_options) {} 3319 cursor_options) {}
3320 3320
3321 virtual Cursor* Clone() OVERRIDE { return new ObjectStoreCursorImpl(this); } 3321 virtual Cursor* Clone() override { return new ObjectStoreCursorImpl(this); }
3322 3322
3323 // IndexedDBBackingStore::Cursor 3323 // IndexedDBBackingStore::Cursor
3324 virtual IndexedDBValue* value() OVERRIDE { return &current_value_; } 3324 virtual IndexedDBValue* value() override { return &current_value_; }
3325 virtual bool LoadCurrentRow() OVERRIDE; 3325 virtual bool LoadCurrentRow() override;
3326 3326
3327 protected: 3327 protected:
3328 virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE { 3328 virtual std::string EncodeKey(const IndexedDBKey& key) override {
3329 return ObjectStoreDataKey::Encode( 3329 return ObjectStoreDataKey::Encode(
3330 cursor_options_.database_id, cursor_options_.object_store_id, key); 3330 cursor_options_.database_id, cursor_options_.object_store_id, key);
3331 } 3331 }
3332 virtual std::string EncodeKey(const IndexedDBKey& key, 3332 virtual std::string EncodeKey(const IndexedDBKey& key,
3333 const IndexedDBKey& primary_key) OVERRIDE { 3333 const IndexedDBKey& primary_key) override {
3334 NOTREACHED(); 3334 NOTREACHED();
3335 return std::string(); 3335 return std::string();
3336 } 3336 }
3337 3337
3338 private: 3338 private:
3339 explicit ObjectStoreCursorImpl(const ObjectStoreCursorImpl* other) 3339 explicit ObjectStoreCursorImpl(const ObjectStoreCursorImpl* other)
3340 : IndexedDBBackingStore::Cursor(other), 3340 : IndexedDBBackingStore::Cursor(other),
3341 current_value_(other->current_value_) {} 3341 current_value_(other->current_value_) {}
3342 3342
3343 IndexedDBValue current_value_; 3343 IndexedDBValue current_value_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 IndexKeyCursorImpl( 3381 IndexKeyCursorImpl(
3382 scoped_refptr<IndexedDBBackingStore> backing_store, 3382 scoped_refptr<IndexedDBBackingStore> backing_store,
3383 IndexedDBBackingStore::Transaction* transaction, 3383 IndexedDBBackingStore::Transaction* transaction,
3384 int64 database_id, 3384 int64 database_id,
3385 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3385 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3386 : IndexedDBBackingStore::Cursor(backing_store, 3386 : IndexedDBBackingStore::Cursor(backing_store,
3387 transaction, 3387 transaction,
3388 database_id, 3388 database_id,
3389 cursor_options) {} 3389 cursor_options) {}
3390 3390
3391 virtual Cursor* Clone() OVERRIDE { return new IndexKeyCursorImpl(this); } 3391 virtual Cursor* Clone() override { return new IndexKeyCursorImpl(this); }
3392 3392
3393 // IndexedDBBackingStore::Cursor 3393 // IndexedDBBackingStore::Cursor
3394 virtual IndexedDBValue* value() OVERRIDE { 3394 virtual IndexedDBValue* value() override {
3395 NOTREACHED(); 3395 NOTREACHED();
3396 return NULL; 3396 return NULL;
3397 } 3397 }
3398 virtual const IndexedDBKey& primary_key() const OVERRIDE { 3398 virtual const IndexedDBKey& primary_key() const override {
3399 return *primary_key_; 3399 return *primary_key_;
3400 } 3400 }
3401 virtual const IndexedDBBackingStore::RecordIdentifier& record_identifier() 3401 virtual const IndexedDBBackingStore::RecordIdentifier& record_identifier()
3402 const OVERRIDE { 3402 const override {
3403 NOTREACHED(); 3403 NOTREACHED();
3404 return record_identifier_; 3404 return record_identifier_;
3405 } 3405 }
3406 virtual bool LoadCurrentRow() OVERRIDE; 3406 virtual bool LoadCurrentRow() override;
3407 3407
3408 protected: 3408 protected:
3409 virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE { 3409 virtual std::string EncodeKey(const IndexedDBKey& key) override {
3410 return IndexDataKey::Encode(cursor_options_.database_id, 3410 return IndexDataKey::Encode(cursor_options_.database_id,
3411 cursor_options_.object_store_id, 3411 cursor_options_.object_store_id,
3412 cursor_options_.index_id, 3412 cursor_options_.index_id,
3413 key); 3413 key);
3414 } 3414 }
3415 virtual std::string EncodeKey(const IndexedDBKey& key, 3415 virtual std::string EncodeKey(const IndexedDBKey& key,
3416 const IndexedDBKey& primary_key) OVERRIDE { 3416 const IndexedDBKey& primary_key) override {
3417 return IndexDataKey::Encode(cursor_options_.database_id, 3417 return IndexDataKey::Encode(cursor_options_.database_id,
3418 cursor_options_.object_store_id, 3418 cursor_options_.object_store_id,
3419 cursor_options_.index_id, 3419 cursor_options_.index_id,
3420 key, 3420 key,
3421 primary_key); 3421 primary_key);
3422 } 3422 }
3423 3423
3424 private: 3424 private:
3425 explicit IndexKeyCursorImpl(const IndexKeyCursorImpl* other) 3425 explicit IndexKeyCursorImpl(const IndexKeyCursorImpl* other)
3426 : IndexedDBBackingStore::Cursor(other), 3426 : IndexedDBBackingStore::Cursor(other),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 IndexCursorImpl( 3496 IndexCursorImpl(
3497 scoped_refptr<IndexedDBBackingStore> backing_store, 3497 scoped_refptr<IndexedDBBackingStore> backing_store,
3498 IndexedDBBackingStore::Transaction* transaction, 3498 IndexedDBBackingStore::Transaction* transaction,
3499 int64 database_id, 3499 int64 database_id,
3500 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options) 3500 const IndexedDBBackingStore::Cursor::CursorOptions& cursor_options)
3501 : IndexedDBBackingStore::Cursor(backing_store, 3501 : IndexedDBBackingStore::Cursor(backing_store,
3502 transaction, 3502 transaction,
3503 database_id, 3503 database_id,
3504 cursor_options) {} 3504 cursor_options) {}
3505 3505
3506 virtual Cursor* Clone() OVERRIDE { return new IndexCursorImpl(this); } 3506 virtual Cursor* Clone() override { return new IndexCursorImpl(this); }
3507 3507
3508 // IndexedDBBackingStore::Cursor 3508 // IndexedDBBackingStore::Cursor
3509 virtual IndexedDBValue* value() OVERRIDE { return &current_value_; } 3509 virtual IndexedDBValue* value() override { return &current_value_; }
3510 virtual const IndexedDBKey& primary_key() const OVERRIDE { 3510 virtual const IndexedDBKey& primary_key() const override {
3511 return *primary_key_; 3511 return *primary_key_;
3512 } 3512 }
3513 virtual const IndexedDBBackingStore::RecordIdentifier& record_identifier() 3513 virtual const IndexedDBBackingStore::RecordIdentifier& record_identifier()
3514 const OVERRIDE { 3514 const override {
3515 NOTREACHED(); 3515 NOTREACHED();
3516 return record_identifier_; 3516 return record_identifier_;
3517 } 3517 }
3518 virtual bool LoadCurrentRow() OVERRIDE; 3518 virtual bool LoadCurrentRow() override;
3519 3519
3520 protected: 3520 protected:
3521 virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE { 3521 virtual std::string EncodeKey(const IndexedDBKey& key) override {
3522 return IndexDataKey::Encode(cursor_options_.database_id, 3522 return IndexDataKey::Encode(cursor_options_.database_id,
3523 cursor_options_.object_store_id, 3523 cursor_options_.object_store_id,
3524 cursor_options_.index_id, 3524 cursor_options_.index_id,
3525 key); 3525 key);
3526 } 3526 }
3527 virtual std::string EncodeKey(const IndexedDBKey& key, 3527 virtual std::string EncodeKey(const IndexedDBKey& key,
3528 const IndexedDBKey& primary_key) OVERRIDE { 3528 const IndexedDBKey& primary_key) override {
3529 return IndexDataKey::Encode(cursor_options_.database_id, 3529 return IndexDataKey::Encode(cursor_options_.database_id,
3530 cursor_options_.object_store_id, 3530 cursor_options_.object_store_id,
3531 cursor_options_.index_id, 3531 cursor_options_.index_id,
3532 key, 3532 key,
3533 primary_key); 3533 primary_key);
3534 } 3534 }
3535 3535
3536 private: 3536 private:
3537 explicit IndexCursorImpl(const IndexCursorImpl* other) 3537 explicit IndexCursorImpl(const IndexCursorImpl* other)
3538 : IndexedDBBackingStore::Cursor(other), 3538 : IndexedDBBackingStore::Cursor(other),
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 return s; 4100 return s;
4101 } 4101 }
4102 4102
4103 4103
4104 class IndexedDBBackingStore::Transaction::BlobWriteCallbackWrapper 4104 class IndexedDBBackingStore::Transaction::BlobWriteCallbackWrapper
4105 : public IndexedDBBackingStore::BlobWriteCallback { 4105 : public IndexedDBBackingStore::BlobWriteCallback {
4106 public: 4106 public:
4107 BlobWriteCallbackWrapper(IndexedDBBackingStore::Transaction* transaction, 4107 BlobWriteCallbackWrapper(IndexedDBBackingStore::Transaction* transaction,
4108 scoped_refptr<BlobWriteCallback> callback) 4108 scoped_refptr<BlobWriteCallback> callback)
4109 : transaction_(transaction), callback_(callback) {} 4109 : transaction_(transaction), callback_(callback) {}
4110 virtual void Run(bool succeeded) OVERRIDE { 4110 virtual void Run(bool succeeded) override {
4111 callback_->Run(succeeded); 4111 callback_->Run(succeeded);
4112 if (succeeded) // Else it's already been deleted during rollback. 4112 if (succeeded) // Else it's already been deleted during rollback.
4113 transaction_->chained_blob_writer_ = NULL; 4113 transaction_->chained_blob_writer_ = NULL;
4114 } 4114 }
4115 4115
4116 private: 4116 private:
4117 virtual ~BlobWriteCallbackWrapper() {} 4117 virtual ~BlobWriteCallbackWrapper() {}
4118 friend class base::RefCounted<IndexedDBBackingStore::BlobWriteCallback>; 4118 friend class base::RefCounted<IndexedDBBackingStore::BlobWriteCallback>;
4119 4119
4120 IndexedDBBackingStore::Transaction* transaction_; 4120 IndexedDBBackingStore::Transaction* transaction_;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 int64_t size, 4265 int64_t size,
4266 base::Time last_modified) 4266 base::Time last_modified)
4267 : is_file_(true), 4267 : is_file_(true),
4268 file_path_(file_path), 4268 file_path_(file_path),
4269 key_(key), 4269 key_(key),
4270 size_(size), 4270 size_(size),
4271 last_modified_(last_modified) { 4271 last_modified_(last_modified) {
4272 } 4272 }
4273 4273
4274 } // namespace content 4274 } // 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