| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 virtual ~DiskFullFactory() {} | 207 virtual ~DiskFullFactory() {} |
| 208 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( | 208 virtual scoped_refptr<IndexedDBBackingStore> OpenBackingStore( |
| 209 const GURL& origin_url, | 209 const GURL& origin_url, |
| 210 const base::FilePath& data_directory, | 210 const base::FilePath& data_directory, |
| 211 net::URLRequestContext* request_context, | 211 net::URLRequestContext* request_context, |
| 212 blink::WebIDBDataLoss* data_loss, | 212 blink::WebIDBDataLoss* data_loss, |
| 213 std::string* data_loss_message, | 213 std::string* data_loss_message, |
| 214 bool* disk_full, | 214 bool* disk_full, |
| 215 leveldb::Status* s) OVERRIDE { | 215 leveldb::Status* s) override { |
| 216 *disk_full = true; | 216 *disk_full = true; |
| 217 *s = leveldb::Status::IOError("Disk is full"); | 217 *s = leveldb::Status::IOError("Disk is full"); |
| 218 return scoped_refptr<IndexedDBBackingStore>(); | 218 return scoped_refptr<IndexedDBBackingStore>(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 DISALLOW_COPY_AND_ASSIGN(DiskFullFactory); | 221 DISALLOW_COPY_AND_ASSIGN(DiskFullFactory); |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { | 224 class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { |
| 225 public: | 225 public: |
| 226 LookingForQuotaErrorMockCallbacks() | 226 LookingForQuotaErrorMockCallbacks() |
| 227 : IndexedDBCallbacks(NULL, 0, 0), error_called_(false) {} | 227 : IndexedDBCallbacks(NULL, 0, 0), error_called_(false) {} |
| 228 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE { | 228 virtual void OnError(const IndexedDBDatabaseError& error) override { |
| 229 error_called_ = true; | 229 error_called_ = true; |
| 230 EXPECT_EQ(blink::WebIDBDatabaseExceptionQuotaError, error.code()); | 230 EXPECT_EQ(blink::WebIDBDatabaseExceptionQuotaError, error.code()); |
| 231 } | 231 } |
| 232 bool error_called() const { return error_called_; } | 232 bool error_called() const { return error_called_; } |
| 233 | 233 |
| 234 private: | 234 private: |
| 235 virtual ~LookingForQuotaErrorMockCallbacks() {} | 235 virtual ~LookingForQuotaErrorMockCallbacks() {} |
| 236 bool error_called_; | 236 bool error_called_; |
| 237 | 237 |
| 238 DISALLOW_COPY_AND_ASSIGN(LookingForQuotaErrorMockCallbacks); | 238 DISALLOW_COPY_AND_ASSIGN(LookingForQuotaErrorMockCallbacks); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 // Ensure it is safe if the store is not open. | 429 // Ensure it is safe if the store is not open. |
| 430 factory()->ForceClose(origin); | 430 factory()->ForceClose(origin); |
| 431 } | 431 } |
| 432 | 432 |
| 433 class UpgradeNeededCallbacks : public MockIndexedDBCallbacks { | 433 class UpgradeNeededCallbacks : public MockIndexedDBCallbacks { |
| 434 public: | 434 public: |
| 435 UpgradeNeededCallbacks() {} | 435 UpgradeNeededCallbacks() {} |
| 436 | 436 |
| 437 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, | 437 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, |
| 438 const IndexedDBDatabaseMetadata& metadata) OVERRIDE { | 438 const IndexedDBDatabaseMetadata& metadata) override { |
| 439 EXPECT_TRUE(connection_.get()); | 439 EXPECT_TRUE(connection_.get()); |
| 440 EXPECT_FALSE(connection.get()); | 440 EXPECT_FALSE(connection.get()); |
| 441 } | 441 } |
| 442 | 442 |
| 443 virtual void OnUpgradeNeeded( | 443 virtual void OnUpgradeNeeded( |
| 444 int64 old_version, | 444 int64 old_version, |
| 445 scoped_ptr<IndexedDBConnection> connection, | 445 scoped_ptr<IndexedDBConnection> connection, |
| 446 const content::IndexedDBDatabaseMetadata& metadata) OVERRIDE { | 446 const content::IndexedDBDatabaseMetadata& metadata) override { |
| 447 connection_ = connection.Pass(); | 447 connection_ = connection.Pass(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 protected: | 450 protected: |
| 451 virtual ~UpgradeNeededCallbacks() {} | 451 virtual ~UpgradeNeededCallbacks() {} |
| 452 | 452 |
| 453 private: | 453 private: |
| 454 DISALLOW_COPY_AND_ASSIGN(UpgradeNeededCallbacks); | 454 DISALLOW_COPY_AND_ASSIGN(UpgradeNeededCallbacks); |
| 455 }; | 455 }; |
| 456 | 456 |
| 457 class ErrorCallbacks : public MockIndexedDBCallbacks { | 457 class ErrorCallbacks : public MockIndexedDBCallbacks { |
| 458 public: | 458 public: |
| 459 ErrorCallbacks() : MockIndexedDBCallbacks(false), saw_error_(false) {} | 459 ErrorCallbacks() : MockIndexedDBCallbacks(false), saw_error_(false) {} |
| 460 | 460 |
| 461 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE { | 461 virtual void OnError(const IndexedDBDatabaseError& error) override { |
| 462 saw_error_= true; | 462 saw_error_= true; |
| 463 } | 463 } |
| 464 bool saw_error() const { return saw_error_; } | 464 bool saw_error() const { return saw_error_; } |
| 465 | 465 |
| 466 private: | 466 private: |
| 467 virtual ~ErrorCallbacks() {} | 467 virtual ~ErrorCallbacks() {} |
| 468 bool saw_error_; | 468 bool saw_error_; |
| 469 | 469 |
| 470 DISALLOW_COPY_AND_ASSIGN(ErrorCallbacks); | 470 DISALLOW_COPY_AND_ASSIGN(ErrorCallbacks); |
| 471 }; | 471 }; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 temp_directory.path()); | 523 temp_directory.path()); |
| 524 EXPECT_TRUE(callbacks->saw_error()); | 524 EXPECT_TRUE(callbacks->saw_error()); |
| 525 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); | 525 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); |
| 526 } | 526 } |
| 527 | 527 |
| 528 // Terminate all pending-close timers. | 528 // Terminate all pending-close timers. |
| 529 factory()->ForceClose(origin); | 529 factory()->ForceClose(origin); |
| 530 } | 530 } |
| 531 | 531 |
| 532 } // namespace content | 532 } // namespace content |
| OLD | NEW |