| Index: ppapi/shared_impl/url_request_info_impl.h
|
| diff --git a/ppapi/shared_impl/url_request_info_impl.h b/ppapi/shared_impl/url_request_info_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4eeacfcc2b746405f1f5962061360b2e1c33b0a5
|
| --- /dev/null
|
| +++ b/ppapi/shared_impl/url_request_info_impl.h
|
| @@ -0,0 +1,138 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef PPAPI_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_
|
| +#define PPAPI_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "ppapi/thunk/ppb_url_request_info_api.h"
|
| +#include "ppapi/shared_impl/resource.h"
|
| +
|
| +namespace ppapi {
|
| +
|
| +namespace thunk {
|
| +class PPB_FileRef_API;
|
| +}
|
| +
|
| +struct PPB_URLRequestInfo_Data {
|
| + struct BodyItem {
|
| + BodyItem();
|
| + explicit BodyItem(const std::string& data);
|
| + BodyItem(Resource* file_ref,
|
| + int64_t start_offset,
|
| + int64_t number_of_bytes,
|
| + PP_Time expected_last_modified_time);
|
| +
|
| + // Set if the input is a file, false means the |data| is valid.
|
| + bool is_file;
|
| +
|
| + std::string data;
|
| +
|
| + // Is is_file is set, these variables are set. Note that the resoruce
|
| + // may still be NULL in some cases, such as deserialization errors.
|
| + //
|
| + // This is a bit tricky. In the plugin side of the proxy, both the file
|
| + // ref and the file_ref_host_resource will be set and valid: the scoped_ptr
|
| + // ensures that the resource is alive for as long as the BodyItem is, and
|
| + // the host resource is for the serialization system to send it over the
|
| + // wire.
|
| + //
|
| + // When we deserialize this in the renderer, the file_refs won't be valid
|
| + // until the host resources are converted to Resource pointers in the
|
| + // PPB_URLRequestInfo_Impl.
|
| + scoped_refptr<Resource> file_ref;
|
| + HostResource file_ref_host_resource;
|
| +
|
| + int64_t start_offset;
|
| + int64_t number_of_bytes;
|
| + PP_Time expected_last_modified_time;
|
| + };
|
| +
|
| + PPB_URLRequestInfo_Data();
|
| + ~PPB_URLRequestInfo_Data();
|
| +
|
| + std::string url;
|
| + std::string method;
|
| + std::string headers;
|
| +
|
| + bool stream_to_file;
|
| + bool follow_redirects;
|
| + bool record_download_progress;
|
| + bool record_upload_progress;
|
| +
|
| + // |has_custom_referrer_url| is set to false if a custom referrer hasn't been
|
| + // set (or has been set to an Undefined Var) and the default referrer should
|
| + // be used. (Setting the custom referrer to an empty string indicates that no
|
| + // referrer header should be generated.)
|
| + bool has_custom_referrer_url;
|
| + std::string custom_referrer_url;
|
| +
|
| + bool allow_cross_origin_requests;
|
| + bool allow_credentials;
|
| +
|
| + // Similar to the custom referrer (above), but for custom content transfer
|
| + // encoding.
|
| + bool has_custom_content_transfer_encoding;
|
| + std::string custom_content_transfer_encoding;
|
| +
|
| + int32_t prefetch_buffer_upper_threshold;
|
| + int32_t prefetch_buffer_lower_threshold;
|
| +
|
| + std::vector<BodyItem> body;
|
| +};
|
| +
|
| +class URLRequestInfoImpl : public ::ppapi::Resource,
|
| + public ::ppapi::thunk::PPB_URLRequestInfo_API {
|
| + public:
|
| + // This constructor initializes the object as a proxy object with the given
|
| + // host resource.
|
| + URLRequestInfoImpl(const HostResource& host_resource,
|
| + const PPB_URLRequestInfo_Data& data);
|
| +
|
| + ~URLRequestInfoImpl();
|
| +
|
| + // Resource overrides.
|
| + virtual thunk::PPB_URLRequestInfo_API* AsPPB_URLRequestInfo_API() OVERRIDE;
|
| +
|
| + // PPB_URLRequestInfo_API implementation.
|
| + virtual PP_Bool SetProperty(PP_URLRequestProperty property,
|
| + PP_Var var) OVERRIDE;
|
| + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) OVERRIDE;
|
| + virtual PP_Bool AppendFileToBody(
|
| + PP_Resource file_ref,
|
| + int64_t start_offset,
|
| + int64_t number_of_bytes,
|
| + PP_Time expected_last_modified_time) OVERRIDE;
|
| + virtual const PPB_URLRequestInfo_Data& GetData() const OVERRIDE;
|
| +
|
| + protected:
|
| + // Constructor used by the webkit implementation.
|
| + URLRequestInfoImpl(PP_Instance instance,
|
| + const PPB_URLRequestInfo_Data& data);
|
| +
|
| + // Checks that the HTTP method is valid, returning the canonicalized version
|
| + // if so. Returns empty string if it's invalid.
|
| + static std::string ValidateMethod(const std::string& method);
|
| +
|
| + bool SetUndefinedProperty(PP_URLRequestProperty property);
|
| + bool SetBooleanProperty(PP_URLRequestProperty property, bool value);
|
| + bool SetIntegerProperty(PP_URLRequestProperty property, int32_t value);
|
| + bool SetStringProperty(PP_URLRequestProperty property,
|
| + const std::string& value);
|
| +
|
| + const PPB_URLRequestInfo_Data& data() const { return data_; }
|
| + PPB_URLRequestInfo_Data& data() { return data_; }
|
| +
|
| + private:
|
| + PPB_URLRequestInfo_Data data_;
|
| +
|
| + DISALLOW_IMPLICIT_CONSTRUCTORS(URLRequestInfoImpl);
|
| +};
|
| +
|
| +} // namespace ppapi
|
| +
|
| +#endif // PPAPI_SHARED_IMPL_URL_REQUEST_INFO_IMPL_H_
|
|
|