| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "ppapi/host/resource_host.h" | 16 #include "ppapi/host/resource_host.h" |
| 17 #include "ppapi/proxy/resource_message_params.h" | 17 #include "ppapi/proxy/resource_message_params.h" |
| 18 #include "ppapi/shared_impl/url_request_info_data.h" | 18 #include "ppapi/shared_impl/url_request_info_data.h" |
| 19 #include "ppapi/shared_impl/url_response_info_data.h" | 19 #include "ppapi/shared_impl/url_response_info_data.h" |
| 20 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 20 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderClient.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 class WebAssociatedURLLoader; |
| 23 class WebLocalFrame; | 24 class WebLocalFrame; |
| 24 class WebURLLoader; | 25 class WebURLLoader; |
| 25 } | 26 } // namespace blink |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| 29 class RendererPpapiHostImpl; | 30 class RendererPpapiHostImpl; |
| 30 | 31 |
| 31 class PepperURLLoaderHost : public ppapi::host::ResourceHost, | 32 class PepperURLLoaderHost : public ppapi::host::ResourceHost, |
| 32 public blink::WebURLLoaderClient { | 33 public blink::WebAssociatedURLLoaderClient { |
| 33 public: | 34 public: |
| 34 // If main_document_loader is true, PP_Resource must be 0 since it will be | 35 // If main_document_loader is true, PP_Resource must be 0 since it will be |
| 35 // pending until the plugin resource attaches to it. | 36 // pending until the plugin resource attaches to it. |
| 36 PepperURLLoaderHost(RendererPpapiHostImpl* host, | 37 PepperURLLoaderHost(RendererPpapiHostImpl* host, |
| 37 bool main_document_loader, | 38 bool main_document_loader, |
| 38 PP_Instance instance, | 39 PP_Instance instance, |
| 39 PP_Resource resource); | 40 PP_Resource resource); |
| 40 ~PepperURLLoaderHost() override; | 41 ~PepperURLLoaderHost() override; |
| 41 | 42 |
| 42 // ResourceHost implementation. | 43 // ResourceHost implementation. |
| 43 int32_t OnResourceMessageReceived( | 44 int32_t OnResourceMessageReceived( |
| 44 const IPC::Message& msg, | 45 const IPC::Message& msg, |
| 45 ppapi::host::HostMessageContext* context) override; | 46 ppapi::host::HostMessageContext* context) override; |
| 46 | 47 |
| 47 // blink::WebURLLoaderClient implementation. | 48 // blink::WebAssociatedURLLoaderClient implementation. |
| 48 bool willFollowRedirect(blink::WebURLLoader* loader, | 49 bool willFollowRedirect(const blink::WebURLRequest& new_request, |
| 49 blink::WebURLRequest& new_request, | |
| 50 const blink::WebURLResponse& redir_response) override; | 50 const blink::WebURLResponse& redir_response) override; |
| 51 void didSendData(blink::WebURLLoader* loader, | 51 void didSendData(unsigned long long bytes_sent, |
| 52 unsigned long long bytes_sent, | |
| 53 unsigned long long total_bytes_to_be_sent) override; | 52 unsigned long long total_bytes_to_be_sent) override; |
| 54 void didReceiveResponse(blink::WebURLLoader* loader, | 53 void didReceiveResponse(const blink::WebURLResponse& response) override; |
| 55 const blink::WebURLResponse& response) override; | 54 void didDownloadData(int data_length) override; |
| 56 void didDownloadData(blink::WebURLLoader* loader, | 55 void didReceiveData(const char* data, int data_length) override; |
| 57 int data_length, | 56 void didFinishLoading(double finish_time) override; |
| 58 int encoded_data_length) override; | 57 void didFail(const blink::WebURLError& error) override; |
| 59 void didReceiveData(blink::WebURLLoader* loader, | |
| 60 const char* data, | |
| 61 int data_length, | |
| 62 int encoded_data_length, | |
| 63 int encoded_body_length) override; | |
| 64 void didFinishLoading(blink::WebURLLoader* loader, | |
| 65 double finish_time, | |
| 66 int64_t total_encoded_data_length) override; | |
| 67 void didFail(blink::WebURLLoader* loader, | |
| 68 const blink::WebURLError& error) override; | |
| 69 | 58 |
| 70 private: | 59 private: |
| 71 // ResourceHost protected overrides. | 60 // ResourceHost protected overrides. |
| 72 void DidConnectPendingHostToResource() override; | 61 void DidConnectPendingHostToResource() override; |
| 73 | 62 |
| 74 // IPC messages | 63 // IPC messages |
| 75 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, | 64 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, |
| 76 const ppapi::URLRequestInfoData& request_data); | 65 const ppapi::URLRequestInfoData& request_data); |
| 77 int32_t InternalOnHostMsgOpen(ppapi::host::HostMessageContext* context, | 66 int32_t InternalOnHostMsgOpen(ppapi::host::HostMessageContext* context, |
| 78 const ppapi::URLRequestInfoData& request_data); | 67 const ppapi::URLRequestInfoData& request_data); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Set to true when this loader can ignore same originl policy. | 115 // Set to true when this loader can ignore same originl policy. |
| 127 bool has_universal_access_; | 116 bool has_universal_access_; |
| 128 | 117 |
| 129 // The loader associated with this request. MAY BE NULL. | 118 // The loader associated with this request. MAY BE NULL. |
| 130 // | 119 // |
| 131 // This will be NULL if the load hasn't been opened yet, or if this is a main | 120 // This will be NULL if the load hasn't been opened yet, or if this is a main |
| 132 // document loader (when registered as a mime type). Therefore, you should | 121 // document loader (when registered as a mime type). Therefore, you should |
| 133 // always NULL check this value before using it. In the case of a main | 122 // always NULL check this value before using it. In the case of a main |
| 134 // document load, you would call the functions on the document to cancel the | 123 // document load, you would call the functions on the document to cancel the |
| 135 // load, etc. since there is no loader. | 124 // load, etc. since there is no loader. |
| 136 std::unique_ptr<blink::WebURLLoader> loader_; | 125 std::unique_ptr<blink::WebAssociatedURLLoader> loader_; |
| 137 | 126 |
| 138 int64_t bytes_sent_; | 127 int64_t bytes_sent_; |
| 139 int64_t total_bytes_to_be_sent_; | 128 int64_t total_bytes_to_be_sent_; |
| 140 int64_t bytes_received_; | 129 int64_t bytes_received_; |
| 141 int64_t total_bytes_to_be_received_; | 130 int64_t total_bytes_to_be_received_; |
| 142 | 131 |
| 143 // Messages sent while the resource host is pending. These will be forwarded | 132 // Messages sent while the resource host is pending. These will be forwarded |
| 144 // to the plugin when the plugin side connects. The pointers are owned by | 133 // to the plugin when the plugin side connects. The pointers are owned by |
| 145 // this object and must be deleted. | 134 // this object and must be deleted. |
| 146 ScopedVector<IPC::Message> pending_replies_; | 135 ScopedVector<IPC::Message> pending_replies_; |
| 147 ScopedVector<IPC::Message> out_of_order_replies_; | 136 ScopedVector<IPC::Message> out_of_order_replies_; |
| 148 | 137 |
| 149 // True when there's a pending DataFromURLResponse call which will send a | 138 // True when there's a pending DataFromURLResponse call which will send a |
| 150 // PpapiPluginMsg_URLLoader_ReceivedResponse to the plugin, which introduces | 139 // PpapiPluginMsg_URLLoader_ReceivedResponse to the plugin, which introduces |
| 151 // ordering constraints on following messages to the plugin. | 140 // ordering constraints on following messages to the plugin. |
| 152 bool pending_response_; | 141 bool pending_response_; |
| 153 | 142 |
| 154 base::WeakPtrFactory<PepperURLLoaderHost> weak_factory_; | 143 base::WeakPtrFactory<PepperURLLoaderHost> weak_factory_; |
| 155 | 144 |
| 156 DISALLOW_COPY_AND_ASSIGN(PepperURLLoaderHost); | 145 DISALLOW_COPY_AND_ASSIGN(PepperURLLoaderHost); |
| 157 }; | 146 }; |
| 158 | 147 |
| 159 } // namespace content | 148 } // namespace content |
| 160 | 149 |
| 161 #endif // CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ | 150 #endif // CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_ |
| OLD | NEW |