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

Side by Side Diff: content/network/url_loader_impl.cc

Issue 2954343005: Merge ResourceRequestBodyImpl and ResourceRequestBody. (Closed)
Patch Set: Remove comment Created 3 years, 5 months 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
« no previous file with comments | « content/common/resource_request_body_impl.cc ('k') | content/public/common/page_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "content/network/url_loader_impl.h" 5 #include "content/network/url_loader_impl.h"
6 6
7 #include "base/task_scheduler/post_task.h" 7 #include "base/task_scheduler/post_task.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/common/net_adapters.h" 10 #include "content/common/net_adapters.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 response->head.effective_connection_type = 66 response->head.effective_connection_type =
67 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN; 67 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
68 68
69 request->GetLoadTimingInfo(&response->head.load_timing); 69 request->GetLoadTimingInfo(&response->head.load_timing);
70 70
71 response->head.request_start = request->creation_time(); 71 response->head.request_start = request->creation_time();
72 response->head.response_start = base::TimeTicks::Now(); 72 response->head.response_start = base::TimeTicks::Now();
73 } 73 }
74 74
75 // A subclass of net::UploadBytesElementReader which owns 75 // A subclass of net::UploadBytesElementReader which owns
76 // ResourceRequestBodyImpl. 76 // ResourceRequestBody.
77 class BytesElementReader : public net::UploadBytesElementReader { 77 class BytesElementReader : public net::UploadBytesElementReader {
78 public: 78 public:
79 BytesElementReader(ResourceRequestBodyImpl* resource_request_body, 79 BytesElementReader(ResourceRequestBody* resource_request_body,
80 const ResourceRequestBodyImpl::Element& element) 80 const ResourceRequestBody::Element& element)
81 : net::UploadBytesElementReader(element.bytes(), element.length()), 81 : net::UploadBytesElementReader(element.bytes(), element.length()),
82 resource_request_body_(resource_request_body) { 82 resource_request_body_(resource_request_body) {
83 DCHECK_EQ(ResourceRequestBodyImpl::Element::TYPE_BYTES, element.type()); 83 DCHECK_EQ(ResourceRequestBody::Element::TYPE_BYTES, element.type());
84 } 84 }
85 85
86 ~BytesElementReader() override {} 86 ~BytesElementReader() override {}
87 87
88 private: 88 private:
89 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_; 89 scoped_refptr<ResourceRequestBody> resource_request_body_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(BytesElementReader); 91 DISALLOW_COPY_AND_ASSIGN(BytesElementReader);
92 }; 92 };
93 93
94 // A subclass of net::UploadFileElementReader which owns 94 // A subclass of net::UploadFileElementReader which owns
95 // ResourceRequestBodyImpl. 95 // ResourceRequestBody.
96 // This class is necessary to ensure the BlobData and any attached shareable 96 // This class is necessary to ensure the BlobData and any attached shareable
97 // files survive until upload completion. 97 // files survive until upload completion.
98 class FileElementReader : public net::UploadFileElementReader { 98 class FileElementReader : public net::UploadFileElementReader {
99 public: 99 public:
100 FileElementReader(ResourceRequestBodyImpl* resource_request_body, 100 FileElementReader(ResourceRequestBody* resource_request_body,
101 base::TaskRunner* task_runner, 101 base::TaskRunner* task_runner,
102 const ResourceRequestBodyImpl::Element& element) 102 const ResourceRequestBody::Element& element)
103 : net::UploadFileElementReader(task_runner, 103 : net::UploadFileElementReader(task_runner,
104 element.path(), 104 element.path(),
105 element.offset(), 105 element.offset(),
106 element.length(), 106 element.length(),
107 element.expected_modification_time()), 107 element.expected_modification_time()),
108 resource_request_body_(resource_request_body) { 108 resource_request_body_(resource_request_body) {
109 DCHECK_EQ(ResourceRequestBodyImpl::Element::TYPE_FILE, element.type()); 109 DCHECK_EQ(ResourceRequestBody::Element::TYPE_FILE, element.type());
110 } 110 }
111 111
112 ~FileElementReader() override {} 112 ~FileElementReader() override {}
113 113
114 private: 114 private:
115 scoped_refptr<ResourceRequestBodyImpl> resource_request_body_; 115 scoped_refptr<ResourceRequestBody> resource_request_body_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(FileElementReader); 117 DISALLOW_COPY_AND_ASSIGN(FileElementReader);
118 }; 118 };
119 119
120 // TODO: copied from content/browser/loader/upload_data_stream_builder.cc. 120 // TODO: copied from content/browser/loader/upload_data_stream_builder.cc.
121 std::unique_ptr<net::UploadDataStream> CreateUploadDataStream( 121 std::unique_ptr<net::UploadDataStream> CreateUploadDataStream(
122 ResourceRequestBodyImpl* body, 122 ResourceRequestBody* body,
123 base::SequencedTaskRunner* file_task_runner) { 123 base::SequencedTaskRunner* file_task_runner) {
124 std::vector<std::unique_ptr<net::UploadElementReader>> element_readers; 124 std::vector<std::unique_ptr<net::UploadElementReader>> element_readers;
125 for (const auto& element : *body->elements()) { 125 for (const auto& element : *body->elements()) {
126 switch (element.type()) { 126 switch (element.type()) {
127 case ResourceRequestBodyImpl::Element::TYPE_BYTES: 127 case ResourceRequestBody::Element::TYPE_BYTES:
128 element_readers.push_back( 128 element_readers.push_back(
129 base::MakeUnique<BytesElementReader>(body, element)); 129 base::MakeUnique<BytesElementReader>(body, element));
130 break; 130 break;
131 case ResourceRequestBodyImpl::Element::TYPE_FILE: 131 case ResourceRequestBody::Element::TYPE_FILE:
132 element_readers.push_back(base::MakeUnique<FileElementReader>( 132 element_readers.push_back(base::MakeUnique<FileElementReader>(
133 body, file_task_runner, element)); 133 body, file_task_runner, element));
134 break; 134 break;
135 case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM: 135 case ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM:
136 NOTIMPLEMENTED(); 136 NOTIMPLEMENTED();
137 break; 137 break;
138 case ResourceRequestBodyImpl::Element::TYPE_BLOB: { 138 case ResourceRequestBody::Element::TYPE_BLOB: {
139 NOTIMPLEMENTED(); 139 NOTIMPLEMENTED();
140 break; 140 break;
141 } 141 }
142 case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY: 142 case ResourceRequestBody::Element::TYPE_DISK_CACHE_ENTRY:
143 case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION: 143 case ResourceRequestBody::Element::TYPE_BYTES_DESCRIPTION:
144 case ResourceRequestBodyImpl::Element::TYPE_UNKNOWN: 144 case ResourceRequestBody::Element::TYPE_UNKNOWN:
145 NOTREACHED(); 145 NOTREACHED();
146 break; 146 break;
147 } 147 }
148 } 148 }
149 149
150 return base::MakeUnique<net::ElementsUploadDataStream>( 150 return base::MakeUnique<net::ElementsUploadDataStream>(
151 std::move(element_readers), body->identifier()); 151 std::move(element_readers), body->identifier());
152 } 152 }
153 153
154 } // namespace 154 } // namespace
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 ReadMore(); 393 ReadMore();
394 } 394 }
395 395
396 void URLLoaderImpl::DeleteIfNeeded() { 396 void URLLoaderImpl::DeleteIfNeeded() {
397 bool has_data_pipe = pending_write_.get() || response_body_stream_.is_valid(); 397 bool has_data_pipe = pending_write_.get() || response_body_stream_.is_valid();
398 if (!connected_ && !has_data_pipe) 398 if (!connected_ && !has_data_pipe)
399 delete this; 399 delete this;
400 } 400 }
401 401
402 } // namespace content 402 } // namespace content
OLDNEW
« no previous file with comments | « content/common/resource_request_body_impl.cc ('k') | content/public/common/page_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698