diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 06:38:52 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 06:38:52 +0000 |
commit | 703a31308be801fa9d7206bd0383d04f22eab2a1 (patch) | |
tree | e9c26259e2f0e9310546321f8d1581288803a3d8 /chrome | |
parent | 90f933a3b3ce799ebd2f1e04c8906ba0c6f514d9 (diff) | |
download | chromium_src-703a31308be801fa9d7206bd0383d04f22eab2a1.zip chromium_src-703a31308be801fa9d7206bd0383d04f22eab2a1.tar.gz chromium_src-703a31308be801fa9d7206bd0383d04f22eab2a1.tar.bz2 |
Highlights of changes:
1. Added entry to ResourceResponseHead so that it contains
either a base::PlatformFile (OS_WIN) or
base::FileDescriptor (OS_POSIX) for passing the file
handle from browser to renderer process.
2. Also added IPC messages for reporting download progress
and ACK message for it. ResourceLoaderBridge::Peer::OnDownloadProgress
is added so that the peer is notified of the download
progress in the renderer process.
3. Load flag to kick start the resource loading for media
files. LOAD_MEDIA_RESOURCE is added so that
ResourceDispatcherHost knows how to use a different
ResourceHandler for handling media resource request.
Review URL: http://codereview.chromium.org/27168
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 9 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_handler.h | 19 | ||||
-rwxr-xr-x | chrome/common/render_messages.h | 7 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 18 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher.cc | 9 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher.h | 1 |
6 files changed, 59 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index ba161e4..6f13305 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -815,6 +815,15 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { response->response_head.content_length = request->GetExpectedContentSize(); request->GetMimeType(&response->response_head.mime_type); + // Structure of ResourceResponseHead depends on the platform, so we do it + // differently. +#if defined(OS_POSIX) + response->response_head.response_data_file.fd = request->response_data_file(); + response->response_head.response_data_file.auto_close = false; +#elif defined(OS_WIN) + response->response_head.response_data_file = request->response_data_file(); +#endif + if (request->ssl_info().cert) { int cert_id = CertStore::GetSharedInstance()->StoreCert( diff --git a/chrome/browser/renderer_host/resource_handler.h b/chrome/browser/renderer_host/resource_handler.h index 01abcb5..1ea5a55 100644 --- a/chrome/browser/renderer_host/resource_handler.h +++ b/chrome/browser/renderer_host/resource_handler.h @@ -12,6 +12,11 @@ #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_HANDLER_H_ +#include "build/build_config.h" +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif +#include "base/platform_file.h" #include "chrome/common/filter_policy.h" #include "net/url_request/url_request_status.h" #include "webkit/glue/resource_loader_bridge.h" @@ -29,6 +34,20 @@ struct ResourceResponseHead // Specifies if the resource should be filtered before being displayed // (insecure resources can be filtered to keep the page secure). FilterPolicy::Type filter_policy; + + // A platform specific handle for a file that carries response data. This + // entry is used if the resource request is of type ResourceType::MEDIA and + // the underlying cache layer keeps the response data in a standalone file. +#if defined(OS_POSIX) + // If the response data file is available, the file handle is stored in + // response_data_file.fd, its value is base::kInvalidPlatformFileValue + // otherwise. + base::FileDescriptor response_data_file; +#elif defined(OS_WIN) + // An asynchronous file handle to the response data file, its value is + // base::kInvalidPlatformFileValue if the file is not available. + base::PlatformFile response_data_file; +#endif }; // Parameters for a synchronous resource response. diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 582bf3a..6258f37 100755 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -377,6 +377,9 @@ struct ParamTraits<ResourceType::Type> { case ResourceType::OBJECT: type = L"OBJECT"; break; + case ResourceType::MEDIA: + type = L"MEDIA"; + break; default: type = L"UNKNOWN"; break; @@ -1334,12 +1337,14 @@ struct ParamTraits<ResourceResponseHead> { ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Write(m, p); WriteParam(m, p.status); WriteParam(m, p.filter_policy); + WriteParam(m, p.response_data_file); } static bool Read(const Message* m, void** iter, param_type* r) { return ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Read(m, iter, r) && ReadParam(m, iter, &r->status) && - ReadParam(m, iter, &r->filter_policy); + ReadParam(m, iter, &r->filter_policy) && + ReadParam(m, iter, &r->response_data_file); } static void Log(const param_type& p, std::wstring* l) { // log more? diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 963afae..009e975 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -175,7 +175,14 @@ IPC_BEGIN_MESSAGES(View) int /* request_id */, ResourceResponseHead) - // Sent as upload progress is being made + // Sent as download progress is being made, size of the resource may be + // unknown, in that case |size| is -1. + IPC_MESSAGE_ROUTED3(ViewMsg_Resource_DownloadProgress, + int /* request_id */, + int64 /* position */, + int64 /* size */) + + // Sent as upload progress is being made. IPC_MESSAGE_ROUTED3(ViewMsg_Resource_UploadProgress, int /* request_id */, int64 /* position */, @@ -1104,8 +1111,13 @@ IPC_BEGIN_MESSAGES(ViewHost) GURL /* last url */, GURL /* url redirected to */) - // Sent when the renderer process to acknowlege receipt of and UploadProgress - // message. + // Sent by the renderer process to acknowledge receipt of a + // DownloadProgress message. + IPC_MESSAGE_ROUTED1(ViewHostMsg_DownloadProgress_ACK, + int /* request_id */) + + // Sent by the renderer process to acknowledge receipt of a + // UploadProgress message. IPC_MESSAGE_ROUTED1(ViewHostMsg_UploadProgress_ACK, int /* request_id */) diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index e9db613..709efed 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -278,6 +278,13 @@ bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { return true; } +void ResourceDispatcher::OnDownloadProgress( + int request_id, int64 position, int64 size) { + // TODO(hclam): delegate this message to + // ResourceLoaderBridge::Peer::OnDownloadProgress and send an ACK message + // back to ResourceDispatcherHost. +} + void ResourceDispatcher::OnUploadProgress( int request_id, int64 position, int64 size) { PendingRequestList::iterator it = pending_requests_.find(request_id); @@ -458,6 +465,7 @@ void ResourceDispatcher::SetDefersLoading(int request_id, bool value) { void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) IPC_MESSAGE_HANDLER(ViewMsg_Resource_UploadProgress, OnUploadProgress) + IPC_MESSAGE_HANDLER(ViewMsg_Resource_DownloadProgress, OnDownloadProgress) IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedResponse, OnReceivedResponse) IPC_MESSAGE_HANDLER(ViewMsg_Resource_ReceivedRedirect, OnReceivedRedirect) IPC_MESSAGE_HANDLER(ViewMsg_Resource_DataReceived, OnReceivedData) @@ -505,6 +513,7 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( bool ResourceDispatcher::IsResourceMessage(const IPC::Message& message) const { switch (message.type()) { + case ViewMsg_Resource_DownloadProgress::ID: case ViewMsg_Resource_UploadProgress::ID: case ViewMsg_Resource_ReceivedResponse::ID: case ViewMsg_Resource_ReceivedRedirect::ID: diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index a6b73d5..a4708ee 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -103,6 +103,7 @@ class ResourceDispatcher : public base::RefCounted<ResourceDispatcher> { typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; // Message response handlers, called by the message handler for this process. + void OnDownloadProgress(int request_id, int64 position, int64 size); void OnUploadProgress(int request_id, int64 position, int64 size); void OnReceivedResponse(int request_id, const ResourceResponseHead&); void OnReceivedRedirect(int request_id, const GURL& new_url); |