Index: content/browser/renderer_host/resource_request_info_impl.cc |
=================================================================== |
--- content/browser/renderer_host/resource_request_info_impl.cc (revision 125274) |
+++ content/browser/renderer_host/resource_request_info_impl.cc (working copy) |
@@ -2,17 +2,54 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
+#include "content/browser/renderer_host/resource_request_info_impl.h" |
#include "content/browser/renderer_host/resource_handler.h" |
#include "content/browser/ssl/ssl_client_auth_handler.h" |
+#include "content/browser/worker_host/worker_service_impl.h" |
#include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
#include "net/url_request/url_request.h" |
#include "webkit/blob/blob_data.h" |
-ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo( |
+namespace content { |
+ |
+// static |
+const ResourceRequestInfo* ResourceRequestInfo::ForRequest( |
+ const net::URLRequest* request) { |
+ return static_cast<const ResourceRequestInfoImpl*>( |
+ request->GetUserData(NULL)); |
+} |
+ |
+// static |
+void ResourceRequestInfo::AllocateForTesting( |
+ net::URLRequest* request, |
+ ResourceContext* context) { |
+ ResourceRequestInfoImpl* info = |
+ new ResourceRequestInfoImpl( |
+ NULL, // handler |
+ PROCESS_TYPE_RENDERER, // process_type |
+ -1, // child_id |
+ MSG_ROUTING_NONE, // route_id |
+ 0, // origin_pid |
+ 0, // request_id |
+ true, // is_main_frame |
+ 0, // frame_id |
+ false, // parent_is_main_frame |
+ 0, // parent_frame_id |
+ ResourceType::MAIN_FRAME, // resource_type |
+ PAGE_TRANSITION_LINK, // transition_type |
+ 0, // upload_size |
+ false, // is_download |
+ true, // allow_download |
+ false, // has_user_gesture |
+ WebKit::WebReferrerPolicyDefault, // referrer_policy |
+ context); // context |
+ info->AssociateWithRequest(request); |
+} |
+ |
+ResourceRequestInfoImpl::ResourceRequestInfoImpl( |
ResourceHandler* handler, |
- content::ProcessType process_type, |
+ ProcessType process_type, |
int child_id, |
int route_id, |
int origin_pid, |
@@ -22,13 +59,13 @@ |
bool parent_is_main_frame, |
int64 parent_frame_id, |
ResourceType::Type resource_type, |
- content::PageTransition transition_type, |
+ PageTransition transition_type, |
uint64 upload_size, |
bool is_download, |
bool allow_download, |
bool has_user_gesture, |
WebKit::WebReferrerPolicy referrer_policy, |
- content::ResourceContext* context) |
+ ResourceContext* context) |
: resource_handler_(handler), |
cross_site_handler_(NULL), |
process_type_(process_type), |
@@ -59,26 +96,101 @@ |
paused_read_bytes_(0) { |
} |
-ResourceDispatcherHostRequestInfo::~ResourceDispatcherHostRequestInfo() { |
- resource_handler_->OnRequestClosed(); |
+ResourceRequestInfoImpl::~ResourceRequestInfoImpl() { |
+ if (resource_handler_) |
+ resource_handler_->OnRequestClosed(); |
} |
-void ResourceDispatcherHostRequestInfo::set_resource_handler( |
+ResourceContext* ResourceRequestInfoImpl::GetContext() const { |
+ return context_; |
+} |
+ |
+int ResourceRequestInfoImpl::GetChildID() const { |
+ return child_id_; |
+} |
+ |
+int ResourceRequestInfoImpl::GetRouteID() const { |
+ return route_id_; |
+} |
+ |
+int ResourceRequestInfoImpl::GetOriginPID() const { |
+ return origin_pid_; |
+} |
+ |
+int ResourceRequestInfoImpl::GetRequestID() const { |
+ return request_id_; |
+} |
+ |
+bool ResourceRequestInfoImpl::IsMainFrame() const { |
+ return is_main_frame_; |
+} |
+ |
+int64 ResourceRequestInfoImpl::GetFrameID() const { |
+ return frame_id_; |
+} |
+ |
+bool ResourceRequestInfoImpl::ParentIsMainFrame() const { |
+ return parent_is_main_frame_; |
+} |
+ |
+int64 ResourceRequestInfoImpl::GetParentFrameID() const { |
+ return parent_frame_id_; |
+} |
+ |
+ResourceType::Type ResourceRequestInfoImpl::GetResourceType() const { |
+ return resource_type_; |
+} |
+ |
+WebKit::WebReferrerPolicy ResourceRequestInfoImpl::GetReferrerPolicy() const { |
+ return referrer_policy_; |
+} |
+ |
+uint64 ResourceRequestInfoImpl::GetUploadSize() const { |
+ return upload_size_; |
+} |
+ |
+bool ResourceRequestInfoImpl::GetAssociatedRenderView( |
+ int* render_process_id, |
+ int* render_view_id) const { |
+ // If the request is from the worker process, find a tab that owns the worker. |
+ if (process_type_ == PROCESS_TYPE_WORKER) { |
+ // Need to display some related UI for this network request - pick an |
+ // arbitrary parent to do so. |
+ if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( |
+ child_id_, render_process_id, render_view_id)) { |
+ *render_process_id = -1; |
+ *render_view_id = -1; |
+ return false; |
+ } |
+ } else { |
+ *render_process_id = child_id_; |
+ *render_view_id = route_id_; |
+ } |
+ return true; |
+} |
+ |
+void ResourceRequestInfoImpl::AssociateWithRequest(net::URLRequest* request) { |
+ request->SetUserData(NULL, this); |
+} |
+ |
+void ResourceRequestInfoImpl::set_resource_handler( |
ResourceHandler* resource_handler) { |
resource_handler_ = resource_handler; |
} |
-void ResourceDispatcherHostRequestInfo::set_login_delegate( |
- content::ResourceDispatcherHostLoginDelegate* ld) { |
+void ResourceRequestInfoImpl::set_login_delegate( |
+ ResourceDispatcherHostLoginDelegate* ld) { |
login_delegate_ = ld; |
} |
-void ResourceDispatcherHostRequestInfo::set_ssl_client_auth_handler( |
+void ResourceRequestInfoImpl::set_ssl_client_auth_handler( |
SSLClientAuthHandler* s) { |
ssl_client_auth_handler_ = s; |
} |
-void ResourceDispatcherHostRequestInfo::set_requested_blob_data( |
+void ResourceRequestInfoImpl::set_requested_blob_data( |
webkit_blob::BlobData* data) { |
requested_blob_data_ = data; |
} |
+ |
+} // namespace content |