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

Side by Side Diff: ppapi/native_client/tests/ppapi_geturl/url_load_request.h

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_
5 #define TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_
6
7 #include <string>
8 #include <vector>
9
10 #include "ppapi/c/ppb_file_io.h"
11 #include "ppapi/c/ppb_file_ref.h"
12 #include "ppapi/c/ppb_url_loader.h"
13 #include "ppapi/c/ppb_url_request_info.h"
14 #include "ppapi/c/ppb_url_response_info.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_stdint.h"
18 #if __native_client__
19 // TODO(polina): add file_io_nacl include
20 #else
21 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
22 #endif
23
24
25 class UrlLoadRequest {
26 public:
27 explicit UrlLoadRequest(PP_Instance instance);
28 ~UrlLoadRequest();
29 bool Load(bool stream_as_file, std::string url);
30
31 void OpenCallback(int32_t pp_error);
32 // Loading/reading via response includes the following asynchronous steps:
33 // 1) URLLoader::Open
34 // 2) URLLoader::ReadResponseBody (in a loop until EOF)
35 void ReadResponseBodyCallback(int32_t pp_error_or_bytes);
36 // Loading/reading via file includes the following asynchronous steps:
37 // 1) URLLoader::Open
38 // 2) URLLoader::FinishStreamingToFile
39 // 3) FileIO::Open
40 // 4) FileIO::Read (in a loop until EOF)
41 void FinishStreamingToFileCallback(int32_t pp_error);
42 void OpenFileBodyCallback(int32_t pp_error);
43 void ReadFileBodyCallback(int32_t pp_error_or_bytes);
44
45 void set_delete_this_after_report() { delete_this_after_report = true; }
46
47 private:
48 bool GetRequiredInterfaces(std::string* error);
49 void Clear();
50
51 void ReadResponseBody();
52 void ReadFileBody();
53
54 bool ReportSuccess();
55 bool ReportFailure(const std::string& error);
56 bool ReportFailure(const std::string& message, int32_t pp_error);
57
58 bool delete_this_after_report;
59
60 std::string url_;
61 bool as_file_;
62
63 PP_Instance instance_;
64 PP_Resource request_;
65 PP_Resource loader_;
66 PP_Resource response_;
67 PP_Resource fileio_;
68
69 const PPB_URLRequestInfo* request_interface_;
70 const PPB_URLResponseInfo* response_interface_;
71 const PPB_URLLoader* loader_interface_;
72 const PPB_FileIO* fileio_interface_;
73
74 char buffer_[1024];
75 std::string url_body_;
76 int32_t read_offset_;
77 };
78
79 #endif // TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698