OLD | NEW |
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 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
| 19 #include "base/time/time.h" |
19 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
20 #include "content/browser/indexed_db/indexed_db.h" | 21 #include "content/browser/indexed_db/indexed_db.h" |
21 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" | 22 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" |
22 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 23 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
23 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 24 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
24 #include "content/browser/indexed_db/indexed_db_metadata.h" | 25 #include "content/browser/indexed_db/indexed_db_metadata.h" |
25 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 26 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
26 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 27 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
27 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
28 #include "content/common/indexed_db/indexed_db_key.h" | 29 #include "content/common/indexed_db/indexed_db_key.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 const std::string& object_store_data_key, | 429 const std::string& object_store_data_key, |
429 IndexedDBValue* value); | 430 IndexedDBValue* value); |
430 | 431 |
431 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored | 432 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored |
432 // under that key. | 433 // under that key. |
433 typedef std::vector<std::pair<BlobEntryKey, std::string> > | 434 typedef std::vector<std::pair<BlobEntryKey, std::string> > |
434 BlobEntryKeyValuePairVec; | 435 BlobEntryKeyValuePairVec; |
435 | 436 |
436 class WriteDescriptor { | 437 class WriteDescriptor { |
437 public: | 438 public: |
438 WriteDescriptor(const GURL& url, int64_t key); | 439 WriteDescriptor(const GURL& url, int64_t key, int64_t size); |
439 WriteDescriptor(const base::FilePath& path, int64_t key); | 440 WriteDescriptor(const base::FilePath& path, |
| 441 int64_t key, |
| 442 int64_t size, |
| 443 base::Time last_modified); |
440 | 444 |
441 bool is_file() const { return is_file_; } | 445 bool is_file() const { return is_file_; } |
442 const GURL& url() const { | 446 const GURL& url() const { |
443 DCHECK(!is_file_); | 447 DCHECK(!is_file_); |
444 return url_; | 448 return url_; |
445 } | 449 } |
446 const base::FilePath& file_path() const { | 450 const base::FilePath& file_path() const { |
447 DCHECK(is_file_); | 451 DCHECK(is_file_); |
448 return file_path_; | 452 return file_path_; |
449 } | 453 } |
450 int64_t key() const { return key_; } | 454 int64_t key() const { return key_; } |
| 455 int64_t size() const { return size_; } |
| 456 base::Time last_modified() const { return last_modified_; } |
451 | 457 |
452 private: | 458 private: |
453 bool is_file_; | 459 bool is_file_; |
454 GURL url_; | 460 GURL url_; |
455 base::FilePath file_path_; | 461 base::FilePath file_path_; |
456 int64_t key_; | 462 int64_t key_; |
| 463 int64_t size_; |
| 464 base::Time last_modified_; |
457 }; | 465 }; |
458 | 466 |
459 class ChainedBlobWriter : public base::RefCounted<ChainedBlobWriter> { | 467 class ChainedBlobWriter : public base::RefCounted<ChainedBlobWriter> { |
460 public: | 468 public: |
461 virtual void set_delegate( | 469 virtual void set_delegate( |
462 scoped_ptr<fileapi::FileWriterDelegate> delegate) = 0; | 470 scoped_ptr<fileapi::FileWriterDelegate> delegate) = 0; |
463 | 471 |
464 // TODO(ericu): Add a reason in the event of failure. | 472 // TODO(ericu): Add a reason in the event of failure. |
465 virtual void ReportWriteCompletion(bool succeeded, | 473 virtual void ReportWriteCompletion(bool succeeded, |
466 int64 bytes_written) = 0; | 474 int64 bytes_written) = 0; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 // will hold a reference to this backing store. | 583 // will hold a reference to this backing store. |
576 IndexedDBActiveBlobRegistry active_blob_registry_; | 584 IndexedDBActiveBlobRegistry active_blob_registry_; |
577 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 585 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
578 | 586 |
579 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); | 587 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStore); |
580 }; | 588 }; |
581 | 589 |
582 } // namespace content | 590 } // namespace content |
583 | 591 |
584 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 592 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
OLD | NEW |