| 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/common/resource_dispatcher.h" | 7 #include "content/common/resource_dispatcher.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "content/common/inter_process_time_ticks_converter.h" | 16 #include "content/common/inter_process_time_ticks_converter.h" |
| 17 #include "content/common/request_extra_data.h" | 17 #include "content/common/request_extra_data.h" |
| 18 #include "content/common/resource_messages.h" | 18 #include "content/common/resource_messages.h" |
| 19 #include "content/public/common/resource_dispatcher_delegate.h" | 19 #include "content/public/common/resource_dispatcher_delegate.h" |
| 20 #include "content/public/common/resource_response.h" | 20 #include "content/public/common/resource_response.h" |
| 21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 #include "net/base/upload_data.h" | |
| 24 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
| 25 #include "webkit/glue/resource_type.h" | 24 #include "webkit/glue/resource_type.h" |
| 25 #include "webkit/glue/webupload_data.h" |
| 26 | 26 |
| 27 using webkit_glue::ResourceLoaderBridge; | 27 using webkit_glue::ResourceLoaderBridge; |
| 28 using webkit_glue::ResourceResponseInfo; | 28 using webkit_glue::ResourceResponseInfo; |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 | 31 |
| 32 // Each resource request is assigned an ID scoped to this process. | 32 // Each resource request is assigned an ID scoped to this process. |
| 33 static int MakeRequestID() { | 33 static int MakeRequestID() { |
| 34 // NOTE: The resource_dispatcher_host also needs probably unique | 34 // NOTE: The resource_dispatcher_host also needs probably unique |
| 35 // request_ids, so they count down from -2 (-1 is a special we're | 35 // request_ids, so they count down from -2 (-1 is a special we're |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void IPCResourceLoaderBridge::AppendDataToUpload(const char* data, | 145 void IPCResourceLoaderBridge::AppendDataToUpload(const char* data, |
| 146 int data_len) { | 146 int data_len) { |
| 147 DCHECK(request_id_ == -1) << "request already started"; | 147 DCHECK(request_id_ == -1) << "request already started"; |
| 148 | 148 |
| 149 // don't bother appending empty data segments | 149 // don't bother appending empty data segments |
| 150 if (data_len == 0) | 150 if (data_len == 0) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 if (!request_.upload_data) | 153 if (!request_.upload_data) |
| 154 request_.upload_data = new net::UploadData(); | 154 request_.upload_data = new WebUploadData(); |
| 155 request_.upload_data->AppendBytes(data, data_len); | 155 request_.upload_data->AppendBytes(data, data_len); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void IPCResourceLoaderBridge::AppendFileRangeToUpload( | 158 void IPCResourceLoaderBridge::AppendFileRangeToUpload( |
| 159 const FilePath& path, uint64 offset, uint64 length, | 159 const FilePath& path, uint64 offset, uint64 length, |
| 160 const base::Time& expected_modification_time) { | 160 const base::Time& expected_modification_time) { |
| 161 DCHECK(request_id_ == -1) << "request already started"; | 161 DCHECK(request_id_ == -1) << "request already started"; |
| 162 | 162 |
| 163 if (!request_.upload_data) | 163 if (!request_.upload_data) |
| 164 request_.upload_data = new net::UploadData(); | 164 request_.upload_data = new WebUploadData(); |
| 165 request_.upload_data->AppendFileRange(path, offset, length, | 165 request_.upload_data->AppendFileRange(path, offset, length, |
| 166 expected_modification_time); | 166 expected_modification_time); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void IPCResourceLoaderBridge::AppendBlobToUpload(const GURL& blob_url) { | 169 void IPCResourceLoaderBridge::AppendBlobToUpload(const GURL& blob_url) { |
| 170 DCHECK(request_id_ == -1) << "request already started"; | 170 DCHECK(request_id_ == -1) << "request already started"; |
| 171 | 171 |
| 172 if (!request_.upload_data) | 172 if (!request_.upload_data) |
| 173 request_.upload_data = new net::UploadData(); | 173 request_.upload_data = new WebUploadData(); |
| 174 request_.upload_data->AppendBlob(blob_url); | 174 request_.upload_data->AppendBlob(blob_url); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void IPCResourceLoaderBridge::SetUploadIdentifier(int64 identifier) { | 177 void IPCResourceLoaderBridge::SetUploadIdentifier(int64 identifier) { |
| 178 DCHECK(request_id_ == -1) << "request already started"; | 178 DCHECK(request_id_ == -1) << "request already started"; |
| 179 | 179 |
| 180 if (!request_.upload_data) | 180 if (!request_.upload_data) |
| 181 request_.upload_data = new net::UploadData(); | 181 request_.upload_data = new WebUploadData(); |
| 182 request_.upload_data->set_identifier(identifier); | 182 request_.upload_data->set_identifier(identifier); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Writes a footer on the message and sends it | 185 // Writes a footer on the message and sends it |
| 186 bool IPCResourceLoaderBridge::Start(Peer* peer) { | 186 bool IPCResourceLoaderBridge::Start(Peer* peer) { |
| 187 if (request_id_ != -1) { | 187 if (request_id_ != -1) { |
| 188 NOTREACHED() << "Starting a request twice"; | 188 NOTREACHED() << "Starting a request twice"; |
| 189 return false; | 189 return false; |
| 190 } | 190 } |
| 191 | 191 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 704 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 705 while (!queue->empty()) { | 705 while (!queue->empty()) { |
| 706 IPC::Message* message = queue->front(); | 706 IPC::Message* message = queue->front(); |
| 707 ReleaseResourcesInDataMessage(*message); | 707 ReleaseResourcesInDataMessage(*message); |
| 708 queue->pop_front(); | 708 queue->pop_front(); |
| 709 delete message; | 709 delete message; |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 | 712 |
| 713 } // namespace content | 713 } // namespace content |
| OLD | NEW |