| 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_BLOB_BLOB_DATA_H_ | 5 #ifndef WEBKIT_BLOB_BLOB_DATA_H_ | 
| 6 #define WEBKIT_BLOB_BLOB_DATA_H_ | 6 #define WEBKIT_BLOB_BLOB_DATA_H_ | 
| 7 | 7 | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" | 
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/time.h" | 13 #include "base/time.h" | 
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" | 
| 15 #include "webkit/base/data_element.h" | 15 #include "webkit/base/data_element.h" | 
| 16 #include "webkit/blob/shareable_file_reference.h" | 16 #include "webkit/blob/shareable_file_reference.h" | 
| 17 #include "webkit/storage/webkit_storage_export.h" | 17 #include "webkit/storage/webkit_storage_export.h" | 
| 18 | 18 | 
| 19 namespace webkit_blob { | 19 namespace webkit_blob { | 
| 20 | 20 | 
| 21 class WEBKIT_STORAGE_EXPORT BlobData : public base::RefCounted<BlobData> { | 21 class WEBKIT_STORAGE_EXPORT BlobData : public base::RefCounted<BlobData> { | 
| 22  public: | 22  public: | 
| 23   typedef webkit_base::DataElement Item; | 23   typedef webkit_base::DataElement Item; | 
| 24 | 24 | 
| 25   BlobData(); | 25   explicit BlobData(const std::string& uuid); | 
| 26 | 26 | 
| 27   void AppendData(const std::string& data) { | 27   void AppendData(const std::string& data) { | 
| 28     AppendData(data.c_str(), data.size()); | 28     AppendData(data.c_str(), data.size()); | 
| 29   } | 29   } | 
| 30 | 30 | 
| 31   void AppendData(const char* data, size_t length); | 31   void AppendData(const char* data, size_t length); | 
| 32 | 32 | 
| 33   void AppendFile(const base::FilePath& file_path, uint64 offset, uint64 length, | 33   void AppendFile(const base::FilePath& file_path, uint64 offset, uint64 length, | 
| 34                   const base::Time& expected_modification_time); | 34                   const base::Time& expected_modification_time); | 
| 35 | 35 | 
| 36   void AppendBlob(const GURL& blob_url, uint64 offset, uint64 length); | 36   void AppendBlob(const std::string& uuid, uint64 offset, uint64 length); | 
| 37 | 37 | 
| 38   void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length, | 38   void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length, | 
| 39                             const base::Time& expected_modification_time); | 39                             const base::Time& expected_modification_time); | 
| 40 | 40 | 
| 41   void AttachShareableFileReference(ShareableFileReference* reference) { | 41   void AttachShareableFileReference(ShareableFileReference* reference) { | 
| 42     shareable_files_.push_back(reference); | 42     shareable_files_.push_back(reference); | 
| 43   } | 43   } | 
| 44 | 44 | 
| 45   const std::vector<Item>& items() const { return items_; } | 45   const std::vector<Item>& items() const { return items_; } | 
| 46 | 46 | 
|  | 47   const std::string& uuid() const { return uuid_; } | 
|  | 48 | 
| 47   const std::string& content_type() const { return content_type_; } | 49   const std::string& content_type() const { return content_type_; } | 
| 48   void set_content_type(const std::string& content_type) { | 50   void set_content_type(const std::string& content_type) { | 
| 49     content_type_ = content_type; | 51     content_type_ = content_type; | 
| 50   } | 52   } | 
| 51 | 53 | 
| 52   const std::string& content_disposition() const { | 54   const std::string& content_disposition() const { | 
| 53     return content_disposition_; | 55     return content_disposition_; | 
| 54   } | 56   } | 
| 55   void set_content_disposition(const std::string& content_disposition) { | 57   void set_content_disposition(const std::string& content_disposition) { | 
| 56     content_disposition_ = content_disposition; | 58     content_disposition_ = content_disposition; | 
| 57   } | 59   } | 
| 58 | 60 | 
| 59   int64 GetMemoryUsage() const; | 61   int64 GetMemoryUsage() const; | 
| 60 | 62 | 
| 61  private: | 63  private: | 
| 62   friend class base::RefCounted<BlobData>; | 64   friend class base::RefCounted<BlobData>; | 
| 63   virtual ~BlobData(); | 65   virtual ~BlobData(); | 
| 64 | 66 | 
|  | 67   std::string uuid_; | 
| 65   std::string content_type_; | 68   std::string content_type_; | 
| 66   std::string content_disposition_; | 69   std::string content_disposition_; | 
| 67   std::vector<Item> items_; | 70   std::vector<Item> items_; | 
| 68   std::vector<scoped_refptr<ShareableFileReference> > shareable_files_; | 71   std::vector<scoped_refptr<ShareableFileReference> > shareable_files_; | 
| 69 | 72 | 
| 70   DISALLOW_COPY_AND_ASSIGN(BlobData); | 73   DISALLOW_COPY_AND_ASSIGN(BlobData); | 
| 71 }; | 74 }; | 
| 72 | 75 | 
| 73 #if defined(UNIT_TEST) | 76 #if defined(UNIT_TEST) | 
| 74 inline bool operator==(const BlobData& a, const BlobData& b) { | 77 inline bool operator==(const BlobData& a, const BlobData& b) { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 86 } | 89 } | 
| 87 | 90 | 
| 88 inline bool operator!=(const BlobData& a, const BlobData& b) { | 91 inline bool operator!=(const BlobData& a, const BlobData& b) { | 
| 89   return !(a == b); | 92   return !(a == b); | 
| 90 } | 93 } | 
| 91 #endif  // defined(UNIT_TEST) | 94 #endif  // defined(UNIT_TEST) | 
| 92 | 95 | 
| 93 }  // namespace webkit_blob | 96 }  // namespace webkit_blob | 
| 94 | 97 | 
| 95 #endif  // WEBKIT_BLOB_BLOB_DATA_H_ | 98 #endif  // WEBKIT_BLOB_BLOB_DATA_H_ | 
| OLD | NEW | 
|---|