OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 PPAPI_CPP_URL_LOADER_H_ | 5 #ifndef PPAPI_CPP_URL_LOADER_H_ |
6 #define PPAPI_CPP_URL_LOADER_H_ | 6 #define PPAPI_CPP_URL_LOADER_H_ |
7 | 7 |
8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
10 | 10 |
11 /// @file | 11 /// @file |
12 /// This file defines the API for loading URLs. | 12 /// This file defines the API for loading URLs. |
13 namespace pp { | 13 namespace pp { |
14 | 14 |
15 class CompletionCallback; | 15 class CompletionCallback; |
16 class Instance; | 16 class Instance; |
17 class URLRequestInfo; | 17 class URLRequestInfo; |
18 class URLResponseInfo; | 18 class URLResponseInfo; |
19 | 19 |
20 /// URLLoader provides an API for loading URLs. | 20 /// URLLoader provides an API for loading URLs. |
21 /// | 21 /// |
22 /// <strong>Example:</strong> | 22 /// <strong>Example:</strong> |
23 /// | 23 /// |
24 /// @code | 24 /// <code> |
25 /// | 25 /// |
26 /// class MyHandler { | 26 /// class MyHandler { |
27 /// public: | 27 /// public: |
28 /// MyHandler(Instance* instance) | 28 /// MyHandler(Instance* instance) |
29 /// : factory_(this), | 29 /// : factory_(this), |
30 /// loader_(instance), | 30 /// loader_(instance), |
31 /// did_open_(false) { | 31 /// did_open_(false) { |
32 /// } | 32 /// } |
33 /// void ProcessURL(const char* url) { | 33 /// void ProcessURL(const char* url) { |
34 /// CompletionCallback* cc = NewCallback(); | 34 /// CompletionCallback* cc = NewCallback(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 /// // Read response headers, etc. | 71 /// // Read response headers, etc. |
72 /// } | 72 /// } |
73 /// void ProcessBytes(const char* bytes, int32_t length) { | 73 /// void ProcessBytes(const char* bytes, int32_t length) { |
74 /// // Do work ... | 74 /// // Do work ... |
75 /// } | 75 /// } |
76 /// pp::CompletionCallbackFactory<MyHandler> factory_; | 76 /// pp::CompletionCallbackFactory<MyHandler> factory_; |
77 /// pp::URLLoader loader_; | 77 /// pp::URLLoader loader_; |
78 /// char buf_[4096]; | 78 /// char buf_[4096]; |
79 /// bool did_open_; | 79 /// bool did_open_; |
80 /// }; | 80 /// }; |
81 /// @endcode | 81 /// </code> |
82 class URLLoader : public Resource { | 82 class URLLoader : public Resource { |
83 public: | 83 public: |
84 /// Default constructor for creating an is_null() | 84 /// Default constructor for creating an is_null() |
85 /// <code>URLLoader</code> object. | 85 /// <code>URLLoader</code> object. |
86 URLLoader() {} | 86 URLLoader() {} |
87 | 87 |
88 // TODO(brettw) remove this when NaCl is updated to use the new version | 88 // TODO(brettw) remove this when NaCl is updated to use the new version |
89 // that takes a pointer. | 89 // that takes a pointer. |
90 explicit URLLoader(const Instance& instance); | 90 explicit URLLoader(const Instance& instance); |
91 | 91 |
92 /// A constructor used when a <code>PP_Resource</code> is provided as a | 92 /// A constructor used when a <code>PP_Resource</code> is provided as a |
93 /// return value whose reference count we need to increment. | 93 /// return value whose reference count we need to increment. |
94 /// | 94 /// |
95 /// @param[in] resource A <code>PP_Resource</code>. | 95 /// @param[in] resource A <code>PP_Resource</code> corresponding to a |
96 /// resource. | |
dmichael (off chromium)
2011/08/23 20:16:11
Maybe say 'URLLoader resource' instead of just 're
jond
2011/08/23 21:15:29
Done.
| |
96 explicit URLLoader(PP_Resource resource); | 97 explicit URLLoader(PP_Resource resource); |
97 | 98 |
98 /// A constructor used to allocate a new URLLoader in the browser. The | 99 /// A constructor used to allocate a new URLLoader in the browser. The |
99 /// resulting object will be <code>is_null</code> if the allocation failed. | 100 /// resulting object will be <code>is_null</code> if the allocation failed. |
100 /// | 101 /// |
101 /// @param[in] instance An <code>Instance</code>. | 102 /// @param[in] instance An <code>Instance</code>. |
102 explicit URLLoader(Instance* instance); | 103 explicit URLLoader(Instance* instance); |
103 | 104 |
104 /// The copy constructor for <code>URLLoader</code>. | 105 /// The copy constructor for <code>URLLoader</code>. |
105 /// | 106 /// |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 /// | 221 /// |
221 /// <strong>Note:</strong> If the <code>URLLoader</code> object is destroyed | 222 /// <strong>Note:</strong> If the <code>URLLoader</code> object is destroyed |
222 /// while it is still open, then it will be implicitly closed so you are not | 223 /// while it is still open, then it will be implicitly closed so you are not |
223 /// required to call Close(). | 224 /// required to call Close(). |
224 void Close(); | 225 void Close(); |
225 }; | 226 }; |
226 | 227 |
227 } // namespace pp | 228 } // namespace pp |
228 | 229 |
229 #endif // PPAPI_CPP_URL_LOADER_H_ | 230 #endif // PPAPI_CPP_URL_LOADER_H_ |
OLD | NEW |