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 3 // found in the LICENSE file. 4 5 #ifndef PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ 6 #define PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/memory/ref_counted.h" 12 #include "ppapi/c/pp_stdint.h" 13 #include "ppapi/c/pp_time.h" 14 #include "ppapi/shared_impl/host_resource.h" 15 #include "ppapi/shared_impl/ppapi_shared_export.h" 16 17 namespace ppapi { 18 19 class Resource; 20 21 struct PPAPI_SHARED_EXPORT URLRequestInfoData { 22 struct PPAPI_SHARED_EXPORT BodyItem { 23 BodyItem(); 24 explicit BodyItem(const std::string& data); 25 BodyItem(Resource* file_ref, 26 int64_t start_offset, 27 int64_t number_of_bytes, 28 PP_Time expected_last_modified_time); 29 30 // Set if the input is a file, false means the |data| is valid. 31 bool is_file; 32 33 std::string data; 34 35 // Is is_file is set, these variables are set. Note that the resource 36 // may still be NULL in some cases, such as deserialization errors. 37 // 38 // This is a bit tricky. In the plugin side of the proxy, both the file ref 39 // and the file_ref_host_resource will be set and valid. The scoped_refptr 40 // ensures that the resource is alive for as long as the BodyItem is. 41 // 42 // When we deserialize this in the renderer, only the 43 // file_ref_host_resource's are serialized over IPC. The file_refs won't be 44 // valid until the host resources are converted to Resource pointers in the 45 // PPB_URLRequestInfo_Impl. 46 scoped_refptr<Resource> file_ref; 47 HostResource file_ref_host_resource; 48 49 int64_t start_offset; 50 int64_t number_of_bytes; 51 PP_Time expected_last_modified_time; 52 53 // If you add more stuff here, be sure to modify the serialization rules in 54 // ppapi_messages.h 55 }; 56 57 URLRequestInfoData(); 58 ~URLRequestInfoData(); 59 60 std::string url; 61 std::string method; 62 std::string headers; 63 64 bool stream_to_file; 65 bool follow_redirects; 66 bool record_download_progress; 67 bool record_upload_progress; 68 69 // |has_custom_referrer_url| is set to false if a custom referrer hasn't been 70 // set (or has been set to an Undefined Var) and the default referrer should 71 // be used. (Setting the custom referrer to an empty string indicates that no 72 // referrer header should be generated.) 73 bool has_custom_referrer_url; 74 std::string custom_referrer_url; 75 76 bool allow_cross_origin_requests; 77 bool allow_credentials; 78 79 // Similar to the custom referrer (above), but for custom content transfer 80 // encoding and custom user agent, respectively. 81 bool has_custom_content_transfer_encoding; 82 std::string custom_content_transfer_encoding; 83 bool has_custom_user_agent; 84 std::string custom_user_agent; 85 86 int32_t prefetch_buffer_upper_threshold; 87 int32_t prefetch_buffer_lower_threshold; 88 89 std::vector<BodyItem> body; 90 91 // If you add more stuff here, be sure to modify the serialization rules in 92 // ppapi_messages.h 93 }; 94 95 } // namespace ppapi 96 97 #endif // PPAPI_SHARED_IMPL_URL_REQUEST_INFO_DATA_H_ 98