| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_LOADER_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | |
| 11 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | 12 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
| 14 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" |
| 15 #include "webkit/plugins/ppapi/callbacks.h" | |
| 16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 14 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 17 #include "webkit/plugins/ppapi/resource.h" | 15 #include "webkit/plugins/ppapi/resource.h" |
| 18 | 16 |
| 19 struct PPB_URLLoader; | 17 struct PPB_URLLoader; |
| 20 struct PPB_URLLoaderTrusted; | 18 struct PPB_URLLoaderTrusted; |
| 21 | 19 |
| 22 namespace WebKit { | 20 namespace WebKit { |
| 23 class WebFrame; | 21 class WebFrame; |
| 24 class WebURL; | 22 class WebURL; |
| 25 } | 23 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 double finish_time); | 82 double finish_time); |
| 85 virtual void didFail(WebKit::WebURLLoader* loader, | 83 virtual void didFail(WebKit::WebURLLoader* loader, |
| 86 const WebKit::WebURLError& error); | 84 const WebKit::WebURLError& error); |
| 87 | 85 |
| 88 // PluginInstance::Observer implementation. | 86 // PluginInstance::Observer implementation. |
| 89 virtual void InstanceDestroyed(PluginInstance* instance); | 87 virtual void InstanceDestroyed(PluginInstance* instance); |
| 90 | 88 |
| 91 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; } | 89 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; } |
| 92 | 90 |
| 93 private: | 91 private: |
| 94 // Check that |callback| is valid (only non-blocking operation is supported) | |
| 95 // and that no callback is already pending. Returns |PP_OK| if okay, else | |
| 96 // |PP_ERROR_...| to be returned to the plugin. | |
| 97 int32_t ValidateCallback(PP_CompletionCallback callback); | |
| 98 | |
| 99 // Sets up |callback| as the pending callback. This should only be called once | |
| 100 // it is certain that |PP_ERROR_WOULDBLOCK| will be returned. | |
| 101 void RegisterCallback(PP_CompletionCallback callback); | |
| 102 | |
| 103 void RunCallback(int32_t result); | 92 void RunCallback(int32_t result); |
| 104 | |
| 105 size_t FillUserBuffer(); | 93 size_t FillUserBuffer(); |
| 106 | 94 |
| 107 // Converts a WebURLResponse to a URLResponseInfo and saves it. | 95 // Converts a WebURLResponse to a URLResponseInfo and saves it. |
| 108 void SaveResponse(const WebKit::WebURLResponse& response); | 96 void SaveResponse(const WebKit::WebURLResponse& response); |
| 109 | 97 |
| 110 int32_t CanRequest(const WebKit::WebFrame* frame, const WebKit::WebURL& url); | 98 int32_t CanRequest(const WebKit::WebFrame* frame, const WebKit::WebURL& url); |
| 111 | 99 |
| 112 // Calls the status_callback_ (if any) with the current upload and download | 100 // Calls the status_callback_ (if any) with the current upload and download |
| 113 // progress. Call this function if you update any of these values to | 101 // progress. Call this function if you update any of these values to |
| 114 // synchronize an out-of-process plugin's state. | 102 // synchronize an out-of-process plugin's state. |
| 115 void UpdateStatus(); | 103 void UpdateStatus(); |
| 116 | 104 |
| 117 // Returns true if the plugin has requested we record download or upload | 105 // Returns true if the plugin has requested we record download or upload |
| 118 // progress. When false, we don't need to update the counters. We go out of | 106 // progress. When false, we don't need to update the counters. We go out of |
| 119 // our way not to allow access to this information unless it's requested, | 107 // our way not to allow access to this information unless it's requested, |
| 120 // even when it would be easier just to return it and not check, so that | 108 // even when it would be easier just to return it and not check, so that |
| 121 // plugins don't depend on access without setting the flag. | 109 // plugins don't depend on access without setting the flag. |
| 122 bool RecordDownloadProgress() const; | 110 bool RecordDownloadProgress() const; |
| 123 bool RecordUploadProgress() const; | 111 bool RecordUploadProgress() const; |
| 124 | 112 |
| 125 // This will be NULL if the instance has been deleted but this | 113 // This will be NULL if the instance has been deleted but this PPB_URLLoader_I
mpl was |
| 126 // PPB_URLLoader_Impl was somehow leaked. In general, you should not need to | 114 // somehow leaked. In general, you should not need to check this for NULL. |
| 127 // check this for NULL. However, if you see a NULL pointer crash, that means | 115 // However, if you see a NULL pointer crash, that means somebody is holding |
| 128 // somebody is holding a reference to this object longer than the | 116 // a reference to this object longer than the PluginInstance's lifetime. |
| 129 // PluginInstance's lifetime. | |
| 130 PluginInstance* instance_; | 117 PluginInstance* instance_; |
| 131 | 118 |
| 132 // If true, then the plugin instance is a full-frame plugin and we're just | 119 // If true, then the plugin instance is a full-frame plugin and we're just |
| 133 // wrapping the main document's loader (i.e. loader_ is null). | 120 // wrapping the main document's loader (i.e. loader_ is null). |
| 134 bool main_document_loader_; | 121 bool main_document_loader_; |
| 135 scoped_ptr<WebKit::WebURLLoader> loader_; | 122 scoped_ptr<WebKit::WebURLLoader> loader_; |
| 136 scoped_refptr<PPB_URLRequestInfo_Impl> request_info_; | 123 scoped_refptr<PPB_URLRequestInfo_Impl> request_info_; |
| 137 scoped_refptr<PPB_URLResponseInfo_Impl> response_info_; | 124 scoped_refptr<PPB_URLResponseInfo_Impl> response_info_; |
| 138 scoped_refptr<TrackedCompletionCallback> pending_callback_; | 125 PP_CompletionCallback pending_callback_; |
| 139 std::deque<char> buffer_; | 126 std::deque<char> buffer_; |
| 140 int64_t bytes_sent_; | 127 int64_t bytes_sent_; |
| 141 int64_t total_bytes_to_be_sent_; | 128 int64_t total_bytes_to_be_sent_; |
| 142 int64_t bytes_received_; | 129 int64_t bytes_received_; |
| 143 int64_t total_bytes_to_be_received_; | 130 int64_t total_bytes_to_be_received_; |
| 144 char* user_buffer_; | 131 char* user_buffer_; |
| 145 size_t user_buffer_size_; | 132 size_t user_buffer_size_; |
| 146 int32_t done_status_; | 133 int32_t done_status_; |
| 147 | 134 |
| 148 bool has_universal_access_; | 135 bool has_universal_access_; |
| 149 | 136 |
| 150 PP_URLLoaderTrusted_StatusCallback status_callback_; | 137 PP_URLLoaderTrusted_StatusCallback status_callback_; |
| 151 | 138 |
| 152 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl); | 139 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl); |
| 153 }; | 140 }; |
| 154 | 141 |
| 155 } // namespace ppapi | 142 } // namespace ppapi |
| 156 } // namespace webkit | 143 } // namespace webkit |
| 157 | 144 |
| 158 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ | 145 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ |
| OLD | NEW |