Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: webkit/plugins/ppapi/ppb_url_loader_impl.h

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
(...skipping 20 matching lines...) Expand all
32 public WebKit::WebURLLoaderClient { 32 public WebKit::WebURLLoaderClient {
33 public: 33 public:
34 PPB_URLLoader_Impl(PP_Instance instance, bool main_document_loader); 34 PPB_URLLoader_Impl(PP_Instance instance, bool main_document_loader);
35 virtual ~PPB_URLLoader_Impl(); 35 virtual ~PPB_URLLoader_Impl();
36 36
37 // Resource overrides. 37 // Resource overrides.
38 virtual ::ppapi::thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE; 38 virtual ::ppapi::thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE;
39 virtual void InstanceWasDeleted() OVERRIDE; 39 virtual void InstanceWasDeleted() OVERRIDE;
40 40
41 // PPB_URLLoader_API implementation. 41 // PPB_URLLoader_API implementation.
42 virtual int32_t Open(PP_Resource request_id, 42 virtual int32_t Open(
43 PP_CompletionCallback callback) OVERRIDE; 43 PP_Resource request_id,
44 virtual int32_t FollowRedirect(PP_CompletionCallback callback) OVERRIDE; 44 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
45 virtual int32_t FollowRedirect(
46 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
45 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, 47 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
46 int64_t* total_bytes_to_be_sent) OVERRIDE; 48 int64_t* total_bytes_to_be_sent) OVERRIDE;
47 virtual PP_Bool GetDownloadProgress( 49 virtual PP_Bool GetDownloadProgress(
48 int64_t* bytes_received, 50 int64_t* bytes_received,
49 int64_t* total_bytes_to_be_received) OVERRIDE; 51 int64_t* total_bytes_to_be_received) OVERRIDE;
50 virtual PP_Resource GetResponseInfo() OVERRIDE; 52 virtual PP_Resource GetResponseInfo() OVERRIDE;
51 virtual int32_t ReadResponseBody(void* buffer, 53 virtual int32_t ReadResponseBody(
52 int32_t bytes_to_read, 54 void* buffer,
53 PP_CompletionCallback callback) OVERRIDE; 55 int32_t bytes_to_read,
56 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
54 virtual int32_t FinishStreamingToFile( 57 virtual int32_t FinishStreamingToFile(
55 PP_CompletionCallback callback) OVERRIDE; 58 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
56 virtual void Close() OVERRIDE; 59 virtual void Close() OVERRIDE;
57 virtual void GrantUniversalAccess() OVERRIDE; 60 virtual void GrantUniversalAccess() OVERRIDE;
58 virtual void SetStatusCallback( 61 virtual void SetStatusCallback(
59 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE; 62 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
60 63
61 // WebKit::WebURLLoaderClient implementation. 64 // WebKit::WebURLLoaderClient implementation.
62 virtual void willSendRequest(WebKit::WebURLLoader* loader, 65 virtual void willSendRequest(WebKit::WebURLLoader* loader,
63 WebKit::WebURLRequest& new_request, 66 WebKit::WebURLRequest& new_request,
64 const WebKit::WebURLResponse& redir_response); 67 const WebKit::WebURLResponse& redir_response);
65 virtual void didSendData(WebKit::WebURLLoader* loader, 68 virtual void didSendData(WebKit::WebURLLoader* loader,
(...skipping 16 matching lines...) Expand all
82 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; } 85 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; }
83 86
84 // Returns the number of bytes currently available for synchronous reading 87 // Returns the number of bytes currently available for synchronous reading
85 // in the loader. 88 // in the loader.
86 int32_t buffer_size() const { return buffer_.size(); } 89 int32_t buffer_size() const { return buffer_.size(); }
87 90
88 private: 91 private:
89 // Check that |callback| is valid (only non-blocking operation is supported) 92 // Check that |callback| is valid (only non-blocking operation is supported)
90 // and that no callback is already pending. Returns |PP_OK| if okay, else 93 // and that no callback is already pending. Returns |PP_OK| if okay, else
91 // |PP_ERROR_...| to be returned to the plugin. 94 // |PP_ERROR_...| to be returned to the plugin.
92 int32_t ValidateCallback(PP_CompletionCallback callback); 95 int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
93 96
94 // Sets up |callback| as the pending callback. This should only be called once 97 // Sets up |callback| as the pending callback. This should only be called once
95 // it is certain that |PP_OK_COMPLETIONPENDING| will be returned. 98 // it is certain that |PP_OK_COMPLETIONPENDING| will be returned.
96 void RegisterCallback(PP_CompletionCallback callback); 99 void RegisterCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
97 100
98 void RunCallback(int32_t result); 101 void RunCallback(int32_t result);
99 102
100 size_t FillUserBuffer(); 103 size_t FillUserBuffer();
101 104
102 // Converts a WebURLResponse to a URLResponseInfo and saves it. 105 // Converts a WebURLResponse to a URLResponseInfo and saves it.
103 void SaveResponse(const WebKit::WebURLResponse& response); 106 void SaveResponse(const WebKit::WebURLResponse& response);
104 107
105 // Calls the status_callback_ (if any) with the current upload and download 108 // Calls the status_callback_ (if any) with the current upload and download
106 // progress. Call this function if you update any of these values to 109 // progress. Call this function if you update any of these values to
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 159
157 PP_URLLoaderTrusted_StatusCallback status_callback_; 160 PP_URLLoaderTrusted_StatusCallback status_callback_;
158 161
159 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl); 162 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
160 }; 163 };
161 164
162 } // namespace ppapi 165 } // namespace ppapi
163 } // namespace webkit 166 } // namespace webkit
164 167
165 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ 168 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_layer_compositor_impl.cc ('k') | webkit/plugins/ppapi/ppb_url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698