OLD | NEW |
1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Resource overrides. | 33 // Resource overrides. |
34 URLLoader* AsURLLoader() { return this; } | 34 URLLoader* AsURLLoader() { return this; } |
35 | 35 |
36 // PPB_URLLoader implementation. | 36 // PPB_URLLoader implementation. |
37 int32_t Open(URLRequestInfo* request, PP_CompletionCallback callback); | 37 int32_t Open(URLRequestInfo* request, PP_CompletionCallback callback); |
38 int32_t FollowRedirect(PP_CompletionCallback callback); | 38 int32_t FollowRedirect(PP_CompletionCallback callback); |
39 int32_t ReadResponseBody(char* buffer, int32_t bytes_to_read, | 39 int32_t ReadResponseBody(char* buffer, int32_t bytes_to_read, |
40 PP_CompletionCallback callback); | 40 PP_CompletionCallback callback); |
41 void Close(); | 41 void Close(); |
42 | 42 |
43 URLResponseInfo* response_info() const { return response_info_; } | |
44 | |
45 // Progress counters. | |
46 int64_t bytes_sent() const { return bytes_sent_; } | |
47 int64_t total_bytes_to_be_sent() const { return total_bytes_to_be_sent_; } | |
48 int64_t bytes_received() const { return bytes_received_; } | |
49 int64_t total_bytes_to_be_received() const { | |
50 return total_bytes_to_be_received_; | |
51 } | |
52 | |
53 private: | |
54 void RunCallback(int32_t result); | |
55 size_t FillUserBuffer(); | |
56 | |
57 // WebKit::WebURLLoaderClient implementation. | 43 // WebKit::WebURLLoaderClient implementation. |
58 virtual void willSendRequest(WebKit::WebURLLoader* loader, | 44 virtual void willSendRequest(WebKit::WebURLLoader* loader, |
59 WebKit::WebURLRequest& new_request, | 45 WebKit::WebURLRequest& new_request, |
60 const WebKit::WebURLResponse& redir_response); | 46 const WebKit::WebURLResponse& redir_response); |
61 virtual void didSendData(WebKit::WebURLLoader* loader, | 47 virtual void didSendData(WebKit::WebURLLoader* loader, |
62 unsigned long long bytes_sent, | 48 unsigned long long bytes_sent, |
63 unsigned long long total_bytes_to_be_sent); | 49 unsigned long long total_bytes_to_be_sent); |
64 virtual void didReceiveResponse(WebKit::WebURLLoader* loader, | 50 virtual void didReceiveResponse(WebKit::WebURLLoader* loader, |
65 const WebKit::WebURLResponse& response); | 51 const WebKit::WebURLResponse& response); |
66 virtual void didReceiveData(WebKit::WebURLLoader* loader, | 52 virtual void didReceiveData(WebKit::WebURLLoader* loader, |
67 const char* data, | 53 const char* data, |
68 int data_length); | 54 int data_length); |
69 virtual void didFinishLoading(WebKit::WebURLLoader* loader); | 55 virtual void didFinishLoading(WebKit::WebURLLoader* loader); |
70 virtual void didFail(WebKit::WebURLLoader* loader, | 56 virtual void didFail(WebKit::WebURLLoader* loader, |
71 const WebKit::WebURLError& error); | 57 const WebKit::WebURLError& error); |
72 | 58 |
| 59 URLResponseInfo* response_info() const { return response_info_; } |
| 60 |
| 61 // Progress counters. |
| 62 int64_t bytes_sent() const { return bytes_sent_; } |
| 63 int64_t total_bytes_to_be_sent() const { return total_bytes_to_be_sent_; } |
| 64 int64_t bytes_received() const { return bytes_received_; } |
| 65 int64_t total_bytes_to_be_received() const { |
| 66 return total_bytes_to_be_received_; |
| 67 } |
| 68 |
| 69 private: |
| 70 void RunCallback(int32_t result); |
| 71 size_t FillUserBuffer(); |
| 72 |
73 scoped_refptr<PluginInstance> instance_; | 73 scoped_refptr<PluginInstance> instance_; |
74 scoped_ptr<WebKit::WebURLLoader> loader_; | 74 scoped_ptr<WebKit::WebURLLoader> loader_; |
75 scoped_refptr<URLResponseInfo> response_info_; | 75 scoped_refptr<URLResponseInfo> response_info_; |
76 PP_CompletionCallback pending_callback_; | 76 PP_CompletionCallback pending_callback_; |
77 std::deque<char> buffer_; | 77 std::deque<char> buffer_; |
78 int64_t bytes_sent_; | 78 int64_t bytes_sent_; |
79 int64_t total_bytes_to_be_sent_; | 79 int64_t total_bytes_to_be_sent_; |
80 int64_t bytes_received_; | 80 int64_t bytes_received_; |
81 int64_t total_bytes_to_be_received_; | 81 int64_t total_bytes_to_be_received_; |
82 char* user_buffer_; | 82 char* user_buffer_; |
83 size_t user_buffer_size_; | 83 size_t user_buffer_size_; |
84 }; | 84 }; |
85 | 85 |
86 } // namespace pepper | 86 } // namespace pepper |
87 | 87 |
88 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ | 88 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ |
OLD | NEW |