| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_COMMON_BLOB_BLOB_DATA_H_ | 5 #ifndef WEBKIT_COMMON_BLOB_BLOB_DATA_H_ |
| 6 #define WEBKIT_COMMON_BLOB_BLOB_DATA_H_ | 6 #define WEBKIT_COMMON_BLOB_BLOB_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 #include "webkit/common/blob/shareable_file_reference.h" | 16 #include "storage/common/blob/shareable_file_reference.h" |
| 17 #include "webkit/common/data_element.h" | 17 #include "storage/common/data_element.h" |
| 18 #include "webkit/common/webkit_storage_common_export.h" | 18 #include "storage/common/storage_export.h" |
| 19 | 19 |
| 20 namespace webkit_blob { | 20 namespace storage { |
| 21 | 21 |
| 22 class WEBKIT_STORAGE_COMMON_EXPORT BlobData | 22 class STORAGE_EXPORT BlobData : public base::RefCounted<BlobData> { |
| 23 : public base::RefCounted<BlobData> { | |
| 24 public: | 23 public: |
| 25 typedef webkit_common::DataElement Item; | 24 typedef webkit_common::DataElement Item; |
| 26 | 25 |
| 27 // TODO(michaeln): remove the empty ctor when we fully transition to uuids. | 26 // TODO(michaeln): remove the empty ctor when we fully transition to uuids. |
| 28 BlobData(); | 27 BlobData(); |
| 29 explicit BlobData(const std::string& uuid); | 28 explicit BlobData(const std::string& uuid); |
| 30 | 29 |
| 31 void AppendData(const std::string& data) { | 30 void AppendData(const std::string& data) { |
| 32 AppendData(data.c_str(), data.size()); | 31 AppendData(data.c_str(), data.size()); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void AppendData(const char* data, size_t length); | 34 void AppendData(const char* data, size_t length); |
| 36 | 35 |
| 37 void AppendFile(const base::FilePath& file_path, uint64 offset, uint64 length, | 36 void AppendFile(const base::FilePath& file_path, |
| 37 uint64 offset, |
| 38 uint64 length, |
| 38 const base::Time& expected_modification_time); | 39 const base::Time& expected_modification_time); |
| 39 void AppendBlob(const std::string& uuid, uint64 offset, uint64 length); | 40 void AppendBlob(const std::string& uuid, uint64 offset, uint64 length); |
| 40 void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length, | 41 void AppendFileSystemFile(const GURL& url, |
| 42 uint64 offset, |
| 43 uint64 length, |
| 41 const base::Time& expected_modification_time); | 44 const base::Time& expected_modification_time); |
| 42 | 45 |
| 43 void AttachShareableFileReference(ShareableFileReference* reference) { | 46 void AttachShareableFileReference(ShareableFileReference* reference) { |
| 44 shareable_files_.push_back(reference); | 47 shareable_files_.push_back(reference); |
| 45 } | 48 } |
| 46 | 49 |
| 47 const std::string& uuid() const { return uuid_; } | 50 const std::string& uuid() const { return uuid_; } |
| 48 const std::vector<Item>& items() const { return items_; } | 51 const std::vector<Item>& items() const { return items_; } |
| 49 const std::string& content_type() const { return content_type_; } | 52 const std::string& content_type() const { return content_type_; } |
| 50 void set_content_type(const std::string& content_type) { | 53 void set_content_type(const std::string& content_type) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return false; | 89 return false; |
| 87 } | 90 } |
| 88 return true; | 91 return true; |
| 89 } | 92 } |
| 90 | 93 |
| 91 inline bool operator!=(const BlobData& a, const BlobData& b) { | 94 inline bool operator!=(const BlobData& a, const BlobData& b) { |
| 92 return !(a == b); | 95 return !(a == b); |
| 93 } | 96 } |
| 94 #endif // defined(UNIT_TEST) | 97 #endif // defined(UNIT_TEST) |
| 95 | 98 |
| 96 } // namespace webkit_blob | 99 } // namespace storage |
| 97 | 100 |
| 98 #endif // WEBKIT_COMMON_BLOB_BLOB_DATA_H_ | 101 #endif // WEBKIT_COMMON_BLOB_BLOB_DATA_H_ |
| OLD | NEW |