| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 double ResourceRequest::default_timeout_interval_ = INT_MAX; | 41 double ResourceRequest::default_timeout_interval_ = INT_MAX; |
| 42 | 42 |
| 43 ResourceRequest::ResourceRequest() : ResourceRequest(KURL()) {} | 43 ResourceRequest::ResourceRequest() : ResourceRequest(KURL()) {} |
| 44 | 44 |
| 45 ResourceRequest::ResourceRequest(const String& url_string) | 45 ResourceRequest::ResourceRequest(const String& url_string) |
| 46 : ResourceRequest(KURL(kParsedURLString, url_string)) {} | 46 : ResourceRequest(KURL(kParsedURLString, url_string)) {} |
| 47 | 47 |
| 48 ResourceRequest::ResourceRequest(const KURL& url) | 48 ResourceRequest::ResourceRequest(const KURL& url) |
| 49 : url_(url), | 49 : url_(url), |
| 50 cache_policy_(WebCachePolicy::kUseProtocolCachePolicy), | |
| 51 timeout_interval_(default_timeout_interval_), | 50 timeout_interval_(default_timeout_interval_), |
| 52 requestor_origin_(nullptr), | 51 requestor_origin_(nullptr), |
| 53 http_method_(HTTPNames::GET), | 52 http_method_(HTTPNames::GET), |
| 54 allow_stored_credentials_(true), | 53 allow_stored_credentials_(true), |
| 55 report_upload_progress_(false), | 54 report_upload_progress_(false), |
| 56 report_raw_headers_(false), | 55 report_raw_headers_(false), |
| 57 has_user_gesture_(false), | 56 has_user_gesture_(false), |
| 58 download_to_file_(false), | 57 download_to_file_(false), |
| 59 use_stream_on_response_(false), | 58 use_stream_on_response_(false), |
| 60 keepalive_(false), | 59 keepalive_(false), |
| 61 should_reset_app_cache_(false), | 60 should_reset_app_cache_(false), |
| 61 cache_policy_(WebCachePolicy::kUseProtocolCachePolicy), |
| 62 service_worker_mode_(WebURLRequest::ServiceWorkerMode::kAll), | 62 service_worker_mode_(WebURLRequest::ServiceWorkerMode::kAll), |
| 63 priority_(kResourceLoadPriorityLowest), | 63 priority_(kResourceLoadPriorityLowest), |
| 64 intra_priority_value_(0), | 64 intra_priority_value_(0), |
| 65 requestor_id_(0), | 65 requestor_id_(0), |
| 66 requestor_process_id_(0), | 66 requestor_process_id_(0), |
| 67 app_cache_host_id_(0), | 67 app_cache_host_id_(0), |
| 68 previews_state_(WebURLRequest::kPreviewsUnspecified), |
| 68 request_context_(WebURLRequest::kRequestContextUnspecified), | 69 request_context_(WebURLRequest::kRequestContextUnspecified), |
| 69 frame_type_(WebURLRequest::kFrameTypeNone), | 70 frame_type_(WebURLRequest::kFrameTypeNone), |
| 70 fetch_request_mode_(WebURLRequest::kFetchRequestModeNoCORS), | 71 fetch_request_mode_(WebURLRequest::kFetchRequestModeNoCORS), |
| 71 fetch_credentials_mode_(WebURLRequest::kFetchCredentialsModeInclude), | 72 fetch_credentials_mode_(WebURLRequest::kFetchCredentialsModeInclude), |
| 72 fetch_redirect_mode_(WebURLRequest::kFetchRedirectModeFollow), | 73 fetch_redirect_mode_(WebURLRequest::kFetchRedirectModeFollow), |
| 73 previews_state_(WebURLRequest::kPreviewsUnspecified), | |
| 74 referrer_policy_(kReferrerPolicyDefault), | 74 referrer_policy_(kReferrerPolicyDefault), |
| 75 did_set_http_referrer_(false), | 75 did_set_http_referrer_(false), |
| 76 check_for_browser_side_navigation_(true), | 76 check_for_browser_side_navigation_(true), |
| 77 ui_start_time_(0), | 77 ui_start_time_(0), |
| 78 is_external_request_(false), | 78 is_external_request_(false), |
| 79 loading_ipc_type_(RuntimeEnabledFeatures::LoadingWithMojoEnabled() | 79 loading_ipc_type_(RuntimeEnabledFeatures::LoadingWithMojoEnabled() |
| 80 ? WebURLRequest::LoadingIPCType::kMojo | 80 ? WebURLRequest::LoadingIPCType::kMojo |
| 81 : WebURLRequest::LoadingIPCType::kChromeIPC), | 81 : WebURLRequest::LoadingIPCType::kChromeIPC), |
| 82 is_same_document_navigation_(false), | 82 is_same_document_navigation_(false), |
| 83 input_perf_metric_report_policy_( | 83 input_perf_metric_report_policy_( |
| 84 InputToLoadPerfMetricReportPolicy::kNoReport), | 84 InputToLoadPerfMetricReportPolicy::kNoReport), |
| 85 redirect_status_(RedirectStatus::kNoRedirect) {} | 85 redirect_status_(RedirectStatus::kNoRedirect) {} |
| 86 | 86 |
| 87 ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data) | 87 ResourceRequest::ResourceRequest(CrossThreadResourceRequestData* data) |
| 88 : ResourceRequest(data->url_) { | 88 : ResourceRequest(data->url_) { |
| 89 SetCachePolicy(data->cache_policy_); | |
| 90 SetTimeoutInterval(data->timeout_interval_); | 89 SetTimeoutInterval(data->timeout_interval_); |
| 91 SetFirstPartyForCookies(data->first_party_for_cookies_); | 90 SetFirstPartyForCookies(data->first_party_for_cookies_); |
| 92 SetRequestorOrigin(data->requestor_origin_); | 91 SetRequestorOrigin(data->requestor_origin_); |
| 93 SetHTTPMethod(AtomicString(data->http_method_)); | 92 SetHTTPMethod(AtomicString(data->http_method_)); |
| 94 SetPriority(data->priority_, data->intra_priority_value_); | 93 SetPriority(data->priority_, data->intra_priority_value_); |
| 95 | 94 |
| 96 http_header_fields_.Adopt(std::move(data->http_headers_)); | 95 http_header_fields_.Adopt(std::move(data->http_headers_)); |
| 97 | 96 |
| 98 SetHTTPBody(data->http_body_); | 97 SetHTTPBody(data->http_body_); |
| 99 SetAttachedCredential(data->attached_credential_); | 98 SetAttachedCredential(data->attached_credential_); |
| 100 SetAllowStoredCredentials(data->allow_stored_credentials_); | 99 SetAllowStoredCredentials(data->allow_stored_credentials_); |
| 101 SetReportUploadProgress(data->report_upload_progress_); | 100 SetReportUploadProgress(data->report_upload_progress_); |
| 102 SetHasUserGesture(data->has_user_gesture_); | 101 SetHasUserGesture(data->has_user_gesture_); |
| 103 SetDownloadToFile(data->download_to_file_); | 102 SetDownloadToFile(data->download_to_file_); |
| 104 SetUseStreamOnResponse(data->use_stream_on_response_); | 103 SetUseStreamOnResponse(data->use_stream_on_response_); |
| 105 SetKeepalive(data->keepalive_); | 104 SetKeepalive(data->keepalive_); |
| 105 SetCachePolicy(data->cache_policy_); |
| 106 SetServiceWorkerMode(data->service_worker_mode_); | 106 SetServiceWorkerMode(data->service_worker_mode_); |
| 107 SetShouldResetAppCache(data->should_reset_app_cache_); | 107 SetShouldResetAppCache(data->should_reset_app_cache_); |
| 108 SetRequestorID(data->requestor_id_); | 108 SetRequestorID(data->requestor_id_); |
| 109 SetRequestorProcessID(data->requestor_process_id_); | 109 SetRequestorProcessID(data->requestor_process_id_); |
| 110 SetAppCacheHostID(data->app_cache_host_id_); | 110 SetAppCacheHostID(data->app_cache_host_id_); |
| 111 SetPreviewsState(data->previews_state_); |
| 111 SetRequestContext(data->request_context_); | 112 SetRequestContext(data->request_context_); |
| 112 SetFrameType(data->frame_type_); | 113 SetFrameType(data->frame_type_); |
| 113 SetFetchRequestMode(data->fetch_request_mode_); | 114 SetFetchRequestMode(data->fetch_request_mode_); |
| 114 SetFetchCredentialsMode(data->fetch_credentials_mode_); | 115 SetFetchCredentialsMode(data->fetch_credentials_mode_); |
| 115 SetFetchRedirectMode(data->fetch_redirect_mode_); | 116 SetFetchRedirectMode(data->fetch_redirect_mode_); |
| 116 SetPreviewsState(data->previews_state_); | |
| 117 referrer_policy_ = data->referrer_policy_; | 117 referrer_policy_ = data->referrer_policy_; |
| 118 did_set_http_referrer_ = data->did_set_http_referrer_; | 118 did_set_http_referrer_ = data->did_set_http_referrer_; |
| 119 check_for_browser_side_navigation_ = data->check_for_browser_side_navigation_; | 119 check_for_browser_side_navigation_ = data->check_for_browser_side_navigation_; |
| 120 ui_start_time_ = data->ui_start_time_; | 120 ui_start_time_ = data->ui_start_time_; |
| 121 is_external_request_ = data->is_external_request_; | 121 is_external_request_ = data->is_external_request_; |
| 122 loading_ipc_type_ = data->loading_ipc_type_; | 122 loading_ipc_type_ = data->loading_ipc_type_; |
| 123 input_perf_metric_report_policy_ = data->input_perf_metric_report_policy_; | 123 input_perf_metric_report_policy_ = data->input_perf_metric_report_policy_; |
| 124 redirect_status_ = data->redirect_status_; | 124 redirect_status_ = data->redirect_status_; |
| 125 } | 125 } |
| 126 | 126 |
| 127 ResourceRequest::ResourceRequest(const ResourceRequest&) = default; | 127 ResourceRequest::ResourceRequest(const ResourceRequest&) = default; |
| 128 | 128 |
| 129 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default; | 129 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default; |
| 130 | 130 |
| 131 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::CopyData() | 131 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::CopyData() |
| 132 const { | 132 const { |
| 133 std::unique_ptr<CrossThreadResourceRequestData> data = | 133 std::unique_ptr<CrossThreadResourceRequestData> data = |
| 134 WTF::MakeUnique<CrossThreadResourceRequestData>(); | 134 WTF::MakeUnique<CrossThreadResourceRequestData>(); |
| 135 data->url_ = Url().Copy(); | 135 data->url_ = Url().Copy(); |
| 136 data->cache_policy_ = GetCachePolicy(); | |
| 137 data->timeout_interval_ = TimeoutInterval(); | 136 data->timeout_interval_ = TimeoutInterval(); |
| 138 data->first_party_for_cookies_ = FirstPartyForCookies().Copy(); | 137 data->first_party_for_cookies_ = FirstPartyForCookies().Copy(); |
| 139 data->requestor_origin_ = | 138 data->requestor_origin_ = |
| 140 RequestorOrigin() ? RequestorOrigin()->IsolatedCopy() : nullptr; | 139 RequestorOrigin() ? RequestorOrigin()->IsolatedCopy() : nullptr; |
| 141 data->http_method_ = HttpMethod().GetString().IsolatedCopy(); | 140 data->http_method_ = HttpMethod().GetString().IsolatedCopy(); |
| 142 data->http_headers_ = HttpHeaderFields().CopyData(); | 141 data->http_headers_ = HttpHeaderFields().CopyData(); |
| 143 data->priority_ = Priority(); | 142 data->priority_ = Priority(); |
| 144 data->intra_priority_value_ = intra_priority_value_; | 143 data->intra_priority_value_ = intra_priority_value_; |
| 145 | 144 |
| 146 if (http_body_) | 145 if (http_body_) |
| 147 data->http_body_ = http_body_->DeepCopy(); | 146 data->http_body_ = http_body_->DeepCopy(); |
| 148 if (attached_credential_) | 147 if (attached_credential_) |
| 149 data->attached_credential_ = attached_credential_->DeepCopy(); | 148 data->attached_credential_ = attached_credential_->DeepCopy(); |
| 150 data->allow_stored_credentials_ = allow_stored_credentials_; | 149 data->allow_stored_credentials_ = allow_stored_credentials_; |
| 151 data->report_upload_progress_ = report_upload_progress_; | 150 data->report_upload_progress_ = report_upload_progress_; |
| 152 data->has_user_gesture_ = has_user_gesture_; | 151 data->has_user_gesture_ = has_user_gesture_; |
| 153 data->download_to_file_ = download_to_file_; | 152 data->download_to_file_ = download_to_file_; |
| 154 data->use_stream_on_response_ = use_stream_on_response_; | 153 data->use_stream_on_response_ = use_stream_on_response_; |
| 155 data->keepalive_ = keepalive_; | 154 data->keepalive_ = keepalive_; |
| 155 data->cache_policy_ = GetCachePolicy(); |
| 156 data->service_worker_mode_ = service_worker_mode_; | 156 data->service_worker_mode_ = service_worker_mode_; |
| 157 data->should_reset_app_cache_ = should_reset_app_cache_; | 157 data->should_reset_app_cache_ = should_reset_app_cache_; |
| 158 data->requestor_id_ = requestor_id_; | 158 data->requestor_id_ = requestor_id_; |
| 159 data->requestor_process_id_ = requestor_process_id_; | 159 data->requestor_process_id_ = requestor_process_id_; |
| 160 data->app_cache_host_id_ = app_cache_host_id_; | 160 data->app_cache_host_id_ = app_cache_host_id_; |
| 161 data->previews_state_ = previews_state_; |
| 161 data->request_context_ = request_context_; | 162 data->request_context_ = request_context_; |
| 162 data->frame_type_ = frame_type_; | 163 data->frame_type_ = frame_type_; |
| 163 data->fetch_request_mode_ = fetch_request_mode_; | 164 data->fetch_request_mode_ = fetch_request_mode_; |
| 164 data->fetch_credentials_mode_ = fetch_credentials_mode_; | 165 data->fetch_credentials_mode_ = fetch_credentials_mode_; |
| 165 data->fetch_redirect_mode_ = fetch_redirect_mode_; | 166 data->fetch_redirect_mode_ = fetch_redirect_mode_; |
| 166 data->previews_state_ = previews_state_; | |
| 167 data->referrer_policy_ = referrer_policy_; | 167 data->referrer_policy_ = referrer_policy_; |
| 168 data->did_set_http_referrer_ = did_set_http_referrer_; | 168 data->did_set_http_referrer_ = did_set_http_referrer_; |
| 169 data->check_for_browser_side_navigation_ = check_for_browser_side_navigation_; | 169 data->check_for_browser_side_navigation_ = check_for_browser_side_navigation_; |
| 170 data->ui_start_time_ = ui_start_time_; | 170 data->ui_start_time_ = ui_start_time_; |
| 171 data->is_external_request_ = is_external_request_; | 171 data->is_external_request_ = is_external_request_; |
| 172 data->loading_ipc_type_ = loading_ipc_type_; | 172 data->loading_ipc_type_ = loading_ipc_type_; |
| 173 data->input_perf_metric_report_policy_ = input_perf_metric_report_policy_; | 173 data->input_perf_metric_report_policy_ = input_perf_metric_report_policy_; |
| 174 data->redirect_status_ = redirect_status_; | 174 data->redirect_status_ = redirect_status_; |
| 175 return data; | 175 return data; |
| 176 } | 176 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // layer. | 426 // layer. |
| 427 if (HttpMethod() == HTTPNames::GET || HttpMethod() == HTTPNames::HEAD) | 427 if (HttpMethod() == HTTPNames::GET || HttpMethod() == HTTPNames::HEAD) |
| 428 return false; | 428 return false; |
| 429 | 429 |
| 430 // For non-GET and non-HEAD methods, always send an Origin header so the | 430 // For non-GET and non-HEAD methods, always send an Origin header so the |
| 431 // server knows we support this feature. | 431 // server knows we support this feature. |
| 432 return true; | 432 return true; |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace blink | 435 } // namespace blink |
| OLD | NEW |