| 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 STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 std::unique_ptr<BlobReader> CreateReader( | 70 std::unique_ptr<BlobReader> CreateReader( |
| 71 FileSystemContext* file_system_context, | 71 FileSystemContext* file_system_context, |
| 72 base::SequencedTaskRunner* file_task_runner) const; | 72 base::SequencedTaskRunner* file_task_runner) const; |
| 73 | 73 |
| 74 // May be accessed on any thread. | 74 // May be accessed on any thread. |
| 75 const std::string& uuid() const; | 75 const std::string& uuid() const; |
| 76 // May be accessed on any thread. | 76 // May be accessed on any thread. |
| 77 const std::string& content_type() const; | 77 const std::string& content_type() const; |
| 78 // May be accessed on any thread. | 78 // May be accessed on any thread. |
| 79 const std::string& content_disposition() const; | 79 const std::string& content_disposition() const; |
| 80 // May be accessed on any thread. In rare cases where the blob is created |
| 81 // as a file from the renderer, this will be uint64_max. |
| 82 uint64_t size() const; |
| 80 | 83 |
| 81 // This call and the destruction of the returned snapshot must be called | 84 // This call and the destruction of the returned snapshot must be called |
| 82 // on the IO thread. If the blob is broken, then we return a nullptr here. | 85 // on the IO thread. If the blob is broken, then we return a nullptr here. |
| 83 // Please do not call this, and use CreateReader instead. It appropriately | 86 // Please do not call this, and use CreateReader instead. It appropriately |
| 84 // waits until the blob is built before having a size (see CalculateSize). | 87 // waits until the blob is built before having a size (see CalculateSize). |
| 85 // TODO(dmurph): Make this protected, where only the BlobReader can call it. | 88 // TODO(dmurph): Make this protected, where only the BlobReader can call it. |
| 86 std::unique_ptr<BlobDataSnapshot> CreateSnapshot() const; | 89 std::unique_ptr<BlobDataSnapshot> CreateSnapshot() const; |
| 87 | 90 |
| 88 private: | 91 private: |
| 89 // Internal class whose destructor is guarenteed to be called on the IO | 92 // Internal class whose destructor is guarenteed to be called on the IO |
| 90 // thread. | 93 // thread. |
| 91 class BlobDataHandleShared | 94 class BlobDataHandleShared |
| 92 : public base::RefCountedThreadSafe<BlobDataHandleShared> { | 95 : public base::RefCountedThreadSafe<BlobDataHandleShared> { |
| 93 public: | 96 public: |
| 94 BlobDataHandleShared(const std::string& uuid, | 97 BlobDataHandleShared(const std::string& uuid, |
| 95 const std::string& content_type, | 98 const std::string& content_type, |
| 96 const std::string& content_disposition, | 99 const std::string& content_disposition, |
| 100 uint64_t size, |
| 97 BlobStorageContext* context); | 101 BlobStorageContext* context); |
| 98 | 102 |
| 99 private: | 103 private: |
| 100 friend class base::DeleteHelper<BlobDataHandleShared>; | 104 friend class base::DeleteHelper<BlobDataHandleShared>; |
| 101 friend class base::RefCountedThreadSafe<BlobDataHandleShared>; | 105 friend class base::RefCountedThreadSafe<BlobDataHandleShared>; |
| 102 friend class BlobDataHandle; | 106 friend class BlobDataHandle; |
| 103 | 107 |
| 104 virtual ~BlobDataHandleShared(); | 108 virtual ~BlobDataHandleShared(); |
| 105 | 109 |
| 106 const std::string uuid_; | 110 const std::string uuid_; |
| 107 const std::string content_type_; | 111 const std::string content_type_; |
| 108 const std::string content_disposition_; | 112 const std::string content_disposition_; |
| 113 const uint64_t size_; |
| 109 base::WeakPtr<BlobStorageContext> context_; | 114 base::WeakPtr<BlobStorageContext> context_; |
| 110 | 115 |
| 111 DISALLOW_COPY_AND_ASSIGN(BlobDataHandleShared); | 116 DISALLOW_COPY_AND_ASSIGN(BlobDataHandleShared); |
| 112 }; | 117 }; |
| 113 | 118 |
| 114 friend class BlobStorageContext; | 119 friend class BlobStorageContext; |
| 115 BlobDataHandle(const std::string& uuid, | 120 BlobDataHandle(const std::string& uuid, |
| 116 const std::string& content_type, | 121 const std::string& content_type, |
| 117 const std::string& content_disposition, | 122 const std::string& content_disposition, |
| 123 uint64_t size, |
| 118 BlobStorageContext* context, | 124 BlobStorageContext* context, |
| 119 base::SequencedTaskRunner* io_task_runner); | 125 base::SequencedTaskRunner* io_task_runner); |
| 120 | 126 |
| 121 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | 127 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 122 scoped_refptr<BlobDataHandleShared> shared_; | 128 scoped_refptr<BlobDataHandleShared> shared_; |
| 123 }; | 129 }; |
| 124 | 130 |
| 125 } // namespace storage | 131 } // namespace storage |
| 126 | 132 |
| 127 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ | 133 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ |
| OLD | NEW |