| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 13 #include "ppapi/c/ppb_url_request_info.h" | |
| 14 #include "ppapi/thunk/ppb_url_request_info_api.h" | 9 #include "ppapi/thunk/ppb_url_request_info_api.h" |
| 15 #include "ppapi/shared_impl/resource.h" | 10 #include "ppapi/shared_impl/url_request_info_impl.h" |
| 16 | 11 |
| 17 namespace WebKit { | 12 namespace WebKit { |
| 18 class WebFrame; | 13 class WebFrame; |
| 14 class WebHTTPBody; |
| 19 class WebURLRequest; | 15 class WebURLRequest; |
| 20 } | 16 } |
| 21 | 17 |
| 22 namespace webkit { | 18 namespace webkit { |
| 23 namespace ppapi { | 19 namespace ppapi { |
| 24 | 20 |
| 25 class PPB_FileRef_Impl; | 21 class PPB_URLRequestInfo_Impl : public ::ppapi::URLRequestInfoImpl { |
| 26 | |
| 27 class PPB_URLRequestInfo_Impl : public ::ppapi::Resource, | |
| 28 public ::ppapi::thunk::PPB_URLRequestInfo_API { | |
| 29 public: | 22 public: |
| 30 explicit PPB_URLRequestInfo_Impl(PP_Instance instance); | 23 explicit PPB_URLRequestInfo_Impl( |
| 24 PP_Instance instance, |
| 25 const ::ppapi::PPB_URLRequestInfo_Data& data); |
| 31 virtual ~PPB_URLRequestInfo_Impl(); | 26 virtual ~PPB_URLRequestInfo_Impl(); |
| 32 | 27 |
| 33 // Resource overrides. | 28 // Creates the WebKit URL request from the current request info. Returns |
| 34 virtual PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE; | 29 // true on success, false if the request is invalid (in which case *dest may |
| 35 | 30 // be partially initialized). |
| 36 // PPB_URLRequestInfo implementation. | 31 bool ToWebURLRequest(WebKit::WebFrame* frame, |
| 37 virtual PP_Bool SetProperty(PP_URLRequestProperty property, | 32 WebKit::WebURLRequest* dest); |
| 38 PP_Var var) OVERRIDE; | |
| 39 virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE; | |
| 40 virtual PP_Bool AppendFileToBody( | |
| 41 PP_Resource file_ref, | |
| 42 int64_t start_offset, | |
| 43 int64_t number_of_bytes, | |
| 44 PP_Time expected_last_modified_time) OVERRIDE; | |
| 45 | |
| 46 WebKit::WebURLRequest ToWebURLRequest(WebKit::WebFrame* frame) const; | |
| 47 | 33 |
| 48 // Whether universal access is required to use this request. | 34 // Whether universal access is required to use this request. |
| 49 bool RequiresUniversalAccess() const; | 35 bool RequiresUniversalAccess() const; |
| 50 | 36 |
| 51 bool SetUndefinedProperty(PP_URLRequestProperty property); | 37 private: |
| 52 bool SetBooleanProperty(PP_URLRequestProperty property, bool value); | 38 friend class URLRequestInfoTest; |
| 53 bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value); | |
| 54 bool SetStringProperty(PP_URLRequestProperty property, | |
| 55 const std::string& value); | |
| 56 | 39 |
| 40 // Checks that the request data is valid and does some canonicalization of |
| 41 // it. Returns false on failure |
| 42 bool ValidateData(); |
| 57 | 43 |
| 58 bool follow_redirects() { return follow_redirects_; } | 44 // Appends the file ref given the Resource pointer associated with it to the |
| 59 | 45 // given HTTP body, returning true on success. |
| 60 bool record_download_progress() const { return record_download_progress_; } | 46 bool AppendFileRefToBody(::ppapi::Resource* file_ref_resource, |
| 61 bool record_upload_progress() const { return record_upload_progress_; } | 47 int64_t start_offset, |
| 62 | 48 int64_t number_of_bytes, |
| 63 bool allow_cross_origin_requests() const { | 49 PP_Time expected_last_modified_time, |
| 64 return allow_cross_origin_requests_; | 50 WebKit::WebHTTPBody *http_body); |
| 65 } | |
| 66 bool allow_credentials() const { return allow_credentials_; } | |
| 67 | |
| 68 int32_t prefetch_buffer_upper_threshold() const { | |
| 69 return prefetch_buffer_upper_threshold_; | |
| 70 } | |
| 71 int32_t prefetch_buffer_lower_threshold() const { | |
| 72 return prefetch_buffer_lower_threshold_; | |
| 73 } | |
| 74 | |
| 75 private: | |
| 76 struct BodyItem; | |
| 77 typedef std::vector<BodyItem> Body; | |
| 78 | |
| 79 std::string url_; | |
| 80 std::string method_; | |
| 81 std::string headers_; | |
| 82 Body body_; | |
| 83 | |
| 84 bool stream_to_file_; | |
| 85 bool follow_redirects_; | |
| 86 bool record_download_progress_; | |
| 87 bool record_upload_progress_; | |
| 88 | |
| 89 // |has_custom_referrer_url_| is set to false if a custom referrer hasn't been | |
| 90 // set (or has been set to an Undefined Var) and the default referrer should | |
| 91 // be used. (Setting the custom referrer to an empty string indicates that no | |
| 92 // referrer header should be generated.) | |
| 93 bool has_custom_referrer_url_; | |
| 94 std::string custom_referrer_url_; | |
| 95 | |
| 96 bool allow_cross_origin_requests_; | |
| 97 bool allow_credentials_; | |
| 98 | |
| 99 // Similar to the custom referrer (above), but for custom content transfer | |
| 100 // encoding. | |
| 101 bool has_custom_content_transfer_encoding_; | |
| 102 std::string custom_content_transfer_encoding_; | |
| 103 | |
| 104 // Specify permitted range for the size of the buffer unconsumed by plugin. | |
| 105 int32_t prefetch_buffer_upper_threshold_; | |
| 106 int32_t prefetch_buffer_lower_threshold_; | |
| 107 | 51 |
| 108 DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl); | 52 DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl); |
| 109 }; | 53 }; |
| 110 | 54 |
| 111 } // namespace ppapi | 55 } // namespace ppapi |
| 112 } // namespace webkit | 56 } // namespace webkit |
| 113 | 57 |
| 114 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ | 58 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_ |
| OLD | NEW |