Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: webkit/glue/resource_request_body.h

Issue 11410019: ********** Chromium Blob hacking (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_GLUE_RESOURCE_REQUEST_BODY_H_ 5 #ifndef WEBKIT_GLUE_RESOURCE_REQUEST_BODY_H_
6 #define WEBKIT_GLUE_RESOURCE_REQUEST_BODY_H_ 6 #define WEBKIT_GLUE_RESOURCE_REQUEST_BODY_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/supports_user_data.h" 13 #include "base/supports_user_data.h"
13 #include "webkit/base/data_element.h" 14 #include "webkit/base/data_element.h"
14 #include "webkit/glue/webkit_glue_export.h" 15 #include "webkit/glue/webkit_glue_export.h"
15 16
16 namespace net { 17 namespace net {
17 class UploadData; 18 class UploadData;
18 class UploadElement; 19 class UploadElement;
19 } 20 }
20 21
21 namespace webkit_blob { 22 namespace webkit_blob {
22 class BlobStorageController; 23 class BlobStorageContext;
23 } 24 }
24 25
25 namespace webkit_glue { 26 namespace webkit_glue {
26 27
27 // A struct used to represent upload data. The data field is populated by 28 // A struct used to represent upload data. The data field is populated by
28 // WebURLLoader from the data given as WebHTTPBody. 29 // WebURLLoader from the data given as WebHTTPBody.
29 class WEBKIT_GLUE_EXPORT ResourceRequestBody 30 class WEBKIT_GLUE_EXPORT ResourceRequestBody
30 : public base::RefCounted<ResourceRequestBody>, 31 : public base::RefCounted<ResourceRequestBody>,
31 public base::SupportsUserData { 32 public base::SupportsUserData {
32 public: 33 public:
33 typedef webkit_base::DataElement Element; 34 typedef webkit_base::DataElement Element;
34 35
35 ResourceRequestBody(); 36 ResourceRequestBody();
36 37
37 void AppendBytes(const char* bytes, int bytes_len); 38 void AppendBytes(const char* bytes, int bytes_len);
38 void AppendFileRange(const FilePath& file_path, 39 void AppendFileRange(const FilePath& file_path,
39 uint64 offset, uint64 length, 40 uint64 offset, uint64 length,
40 const base::Time& expected_modification_time); 41 const base::Time& expected_modification_time);
41 void AppendBlob(const GURL& blob_url); 42 void AppendBlob(const std::string& uuid);
42 void AppendFileSystemFileRange(const GURL& url, uint64 offset, uint64 length, 43 void AppendFileSystemFileRange(const GURL& url, uint64 offset, uint64 length,
43 const base::Time& expected_modification_time); 44 const base::Time& expected_modification_time);
44 45
45 // Creates a new UploadData from this request body. This also resolves 46 // Creates a new UploadData from this request body. This also resolves
46 // any blob references using given |blob_controller|. 47 // any blob references using given |blob_controller|.
47 // TODO(kinuko): Clean up this hack. 48 // TODO(kinuko): Clean up this hack.
48 net::UploadData* ResolveElementsAndCreateUploadData( 49 net::UploadData* ResolveElementsAndCreateUploadData(
49 webkit_blob::BlobStorageController* blob_controller); 50 webkit_blob::BlobStorageContext* blob_context);
50 51
51 const std::vector<Element>* elements() const { return &elements_; } 52 const std::vector<Element>* elements() const { return &elements_; }
52 std::vector<Element>* elements_mutable() { return &elements_; } 53 std::vector<Element>* elements_mutable() { return &elements_; }
53 void swap_elements(std::vector<Element>* elements) { 54 void swap_elements(std::vector<Element>* elements) {
54 elements_.swap(*elements); 55 elements_.swap(*elements);
55 } 56 }
56 57
57 // Identifies a particular upload instance, which is used by the cache to 58 // Identifies a particular upload instance, which is used by the cache to
58 // formulate a cache key. This value should be unique across browser 59 // formulate a cache key. This value should be unique across browser
59 // sessions. A value of 0 is used to indicate an unspecified identifier. 60 // sessions. A value of 0 is used to indicate an unspecified identifier.
60 void set_identifier(int64 id) { identifier_ = id; } 61 void set_identifier(int64 id) { identifier_ = id; }
61 int64 identifier() const { return identifier_; } 62 int64 identifier() const { return identifier_; }
62 63
63 private: 64 private:
64 friend class base::RefCounted<ResourceRequestBody>; 65 friend class base::RefCounted<ResourceRequestBody>;
65 virtual ~ResourceRequestBody(); 66 virtual ~ResourceRequestBody();
66 67
67 // Resolves the |blob_url| using |blob_controller| and appends resolved 68 // Resolves the |blob_url| using |blob_controller| and appends resolved
68 // items to |resolved_elements|. 69 // items to |resolved_elements|.
69 void ResolveBlobReference(webkit_blob::BlobStorageController* blob_controller, 70 void ResolveBlobReference(webkit_blob::BlobStorageContext* blob_context,
70 const GURL& blob_url, 71 const std::string& uuid,
71 std::vector<const Element*>* resolved_elements); 72 std::vector<const Element*>* resolved_elements);
72 73
73 std::vector<Element> elements_; 74 std::vector<Element> elements_;
74 int64 identifier_; 75 int64 identifier_;
75 76
76 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody); 77 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody);
77 }; 78 };
78 79
79 } // namespace webkit_glue 80 } // namespace webkit_glue
80 81
81 #endif // WEBKIT_GLUE_RESOURCE_REQUEST_BODY_H_ 82 #endif // WEBKIT_GLUE_RESOURCE_REQUEST_BODY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698