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 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 5 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
6 | 6 |
7 #include "content/browser/renderer_host/resource_handler.h" | 7 #include "content/browser/renderer_host/resource_handler.h" |
8 #include "content/browser/ssl/ssl_client_auth_handler.h" | 8 #include "content/browser/ssl/ssl_client_auth_handler.h" |
| 9 #include "content/browser/worker_host/worker_service_impl.h" |
9 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" | 10 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
10 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
11 #include "webkit/blob/blob_data.h" | 12 #include "webkit/blob/blob_data.h" |
12 | 13 |
| 14 using content::WorkerServiceImpl; |
| 15 |
13 ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo( | 16 ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo( |
14 ResourceHandler* handler, | 17 ResourceHandler* handler, |
15 content::ProcessType process_type, | 18 content::ProcessType process_type, |
16 int child_id, | 19 int child_id, |
17 int route_id, | 20 int route_id, |
18 int origin_pid, | 21 int origin_pid, |
19 int request_id, | 22 int request_id, |
20 bool is_main_frame, | 23 bool is_main_frame, |
21 int64 frame_id, | 24 int64 frame_id, |
22 bool parent_is_main_frame, | 25 bool parent_is_main_frame, |
23 int64 parent_frame_id, | 26 int64 parent_frame_id, |
24 ResourceType::Type resource_type, | 27 ResourceType::Type resource_type, |
25 content::PageTransition transition_type, | 28 content::PageTransition transition_type, |
26 uint64 upload_size, | 29 uint64 upload_size, |
27 bool is_download, | 30 bool is_download, |
28 bool allow_download, | 31 bool allow_download, |
29 bool has_user_gesture, | 32 bool has_user_gesture, |
30 WebKit::WebReferrerPolicy referrer_policy, | 33 WebKit::WebReferrerPolicy referrer_policy, |
31 content::ResourceContext* context) | 34 content::ResourceContext* context) |
32 : resource_handler_(handler), | 35 : ResourceRequestInfo(context, |
| 36 child_id, |
| 37 route_id, |
| 38 origin_pid, |
| 39 request_id, |
| 40 is_main_frame, |
| 41 frame_id, |
| 42 parent_is_main_frame, |
| 43 parent_frame_id, |
| 44 resource_type, |
| 45 referrer_policy, |
| 46 upload_size), |
| 47 resource_handler_(handler), |
33 cross_site_handler_(NULL), | 48 cross_site_handler_(NULL), |
34 process_type_(process_type), | 49 process_type_(process_type), |
35 child_id_(child_id), | |
36 route_id_(route_id), | |
37 origin_pid_(origin_pid), | |
38 request_id_(request_id), | |
39 is_main_frame_(is_main_frame), | |
40 frame_id_(frame_id), | |
41 parent_is_main_frame_(parent_is_main_frame), | |
42 parent_frame_id_(parent_frame_id), | |
43 pending_data_count_(0), | 50 pending_data_count_(0), |
44 is_download_(is_download), | 51 is_download_(is_download), |
45 allow_download_(allow_download), | 52 allow_download_(allow_download), |
46 has_user_gesture_(has_user_gesture), | 53 has_user_gesture_(has_user_gesture), |
47 pause_count_(0), | 54 pause_count_(0), |
48 resource_type_(resource_type), | |
49 transition_type_(transition_type), | 55 transition_type_(transition_type), |
50 upload_size_(upload_size), | |
51 last_upload_position_(0), | 56 last_upload_position_(0), |
52 waiting_for_upload_progress_ack_(false), | 57 waiting_for_upload_progress_ack_(false), |
53 memory_cost_(0), | 58 memory_cost_(0), |
54 referrer_policy_(referrer_policy), | |
55 context_(context), | |
56 is_paused_(false), | 59 is_paused_(false), |
57 called_on_response_started_(false), | 60 called_on_response_started_(false), |
58 has_started_reading_(false), | 61 has_started_reading_(false), |
59 paused_read_bytes_(0) { | 62 paused_read_bytes_(0) { |
60 } | 63 } |
61 | 64 |
62 ResourceDispatcherHostRequestInfo::~ResourceDispatcherHostRequestInfo() { | 65 ResourceDispatcherHostRequestInfo::~ResourceDispatcherHostRequestInfo() { |
63 resource_handler_->OnRequestClosed(); | 66 if (resource_handler_) |
| 67 resource_handler_->OnRequestClosed(); |
| 68 } |
| 69 |
| 70 bool ResourceDispatcherHostRequestInfo::GetAssociatedRenderView( |
| 71 int* render_process_id, |
| 72 int* render_view_id) const { |
| 73 // If the request is from the worker process, find a tab that owns the worker. |
| 74 if (process_type_ == content::PROCESS_TYPE_WORKER) { |
| 75 // Need to display some related UI for this network request - pick an |
| 76 // arbitrary parent to do so. |
| 77 if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker( |
| 78 child_id_, render_process_id, render_view_id)) { |
| 79 *render_process_id = -1; |
| 80 *render_view_id = -1; |
| 81 return false; |
| 82 } |
| 83 } else { |
| 84 *render_process_id = child_id_; |
| 85 *render_view_id = route_id_; |
| 86 } |
| 87 return true; |
64 } | 88 } |
65 | 89 |
66 void ResourceDispatcherHostRequestInfo::set_resource_handler( | 90 void ResourceDispatcherHostRequestInfo::set_resource_handler( |
67 ResourceHandler* resource_handler) { | 91 ResourceHandler* resource_handler) { |
68 resource_handler_ = resource_handler; | 92 resource_handler_ = resource_handler; |
69 } | 93 } |
70 | 94 |
71 void ResourceDispatcherHostRequestInfo::set_login_delegate( | 95 void ResourceDispatcherHostRequestInfo::set_login_delegate( |
72 content::ResourceDispatcherHostLoginDelegate* ld) { | 96 content::ResourceDispatcherHostLoginDelegate* ld) { |
73 login_delegate_ = ld; | 97 login_delegate_ = ld; |
74 } | 98 } |
75 | 99 |
76 void ResourceDispatcherHostRequestInfo::set_ssl_client_auth_handler( | 100 void ResourceDispatcherHostRequestInfo::set_ssl_client_auth_handler( |
77 SSLClientAuthHandler* s) { | 101 SSLClientAuthHandler* s) { |
78 ssl_client_auth_handler_ = s; | 102 ssl_client_auth_handler_ = s; |
79 } | 103 } |
80 | 104 |
81 void ResourceDispatcherHostRequestInfo::set_requested_blob_data( | 105 void ResourceDispatcherHostRequestInfo::set_requested_blob_data( |
82 webkit_blob::BlobData* data) { | 106 webkit_blob::BlobData* data) { |
83 requested_blob_data_ = data; | 107 requested_blob_data_ = data; |
84 } | 108 } |
OLD | NEW |