OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" |
| 10 #include "base/time/time.h" |
| 11 #include "webkit/common/blob/shareable_file_reference.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class IndexedDBBlobInfo { |
| 16 public: |
| 17 typedef webkit_blob::ShareableFileReference::FinalReleaseCallback |
| 18 ReleaseCallback; |
| 19 IndexedDBBlobInfo(); |
| 20 ~IndexedDBBlobInfo(); |
| 21 // These two are used for Blobs. |
| 22 IndexedDBBlobInfo(const std::string& uuid, |
| 23 const base::string16& type, |
| 24 int64 size); |
| 25 IndexedDBBlobInfo(const base::string16& type, int64 size, int64 key); |
| 26 // These two are used for Files. |
| 27 IndexedDBBlobInfo(const base::FilePath& file_path, |
| 28 const base::string16& file_name, |
| 29 const base::string16& type); |
| 30 IndexedDBBlobInfo(int64 key, |
| 31 const base::string16& type, |
| 32 const base::string16& file_name); |
| 33 |
| 34 bool is_file() const { return is_file_; } |
| 35 const std::string& uuid() const { return uuid_; } |
| 36 const base::string16& type() const { return type_; } |
| 37 int64 size() const { return size_; } |
| 38 const base::string16& file_name() const { return file_name_; } |
| 39 int64 key() const { return key_; } |
| 40 const base::FilePath& file_path() const { return file_path_; } |
| 41 const base::Time& last_modified() const { return last_modified_; } |
| 42 const base::Closure& mark_used_callback() const { |
| 43 return mark_used_callback_; |
| 44 } |
| 45 const ReleaseCallback& release_callback() const { return release_callback_; } |
| 46 |
| 47 void set_size(int64 size); |
| 48 void set_uuid(const std::string& uuid); |
| 49 void set_file_path(const base::FilePath& file_path); |
| 50 void set_last_modified(const base::Time& time); |
| 51 void set_key(int64 key); |
| 52 void set_mark_used_callback(const base::Closure& mark_used_callback); |
| 53 void set_release_callback(const ReleaseCallback& release_callback); |
| 54 |
| 55 private: |
| 56 bool is_file_; |
| 57 std::string uuid_; // Always for Blob; sometimes for File. |
| 58 base::string16 type_; // Mime type. |
| 59 int64 size_; // -1 if unknown for File. |
| 60 base::string16 file_name_; // Only for File. |
| 61 base::FilePath file_path_; // Only for File. |
| 62 base::Time last_modified_; // Only for File; valid only if size is. |
| 63 |
| 64 // Valid only when this comes out of the database. |
| 65 int64 key_; |
| 66 base::Closure mark_used_callback_; |
| 67 ReleaseCallback release_callback_; |
| 68 }; |
| 69 |
| 70 } // namespace content |
| 71 |
| 72 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_ |
OLD | NEW |