- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / thunk / ppb_url_loader_api.h
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
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_THUNK_URL_LOADER_API_H_
6 #define PPAPI_THUNK_URL_LOADER_API_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "ppapi/c/ppb_url_loader.h"
10 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
11
12 namespace ppapi {
13
14 class TrackedCallback;
15 struct URLRequestInfoData;
16 struct URLResponseInfoData;
17
18 namespace thunk {
19
20 class PPB_URLLoader_API {
21  public:
22   virtual ~PPB_URLLoader_API() {}
23
24   // Open given the resource ID of a PPB_URLRequestInfo resource.
25   virtual int32_t Open(PP_Resource request_id,
26                        scoped_refptr<TrackedCallback> callback) = 0;
27
28   // Internal open given a URLRequestInfoData and requestor_pid, which
29   // indicates the process that requested and will consume the data.
30   // Pass 0 for requestor_pid to indicate the current process.
31   virtual int32_t Open(const URLRequestInfoData& data,
32                        int requestor_pid,
33                        scoped_refptr<TrackedCallback> callback) = 0;
34
35   virtual int32_t FollowRedirect(scoped_refptr<TrackedCallback> callback) = 0;
36   virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
37                                     int64_t* total_bytes_to_be_sent) = 0;
38   virtual PP_Bool GetDownloadProgress(int64_t* bytes_received,
39                                       int64_t* total_bytes_to_be_received) = 0;
40   virtual PP_Resource GetResponseInfo() = 0;
41   virtual int32_t ReadResponseBody(void* buffer,
42                                    int32_t bytes_to_read,
43                                    scoped_refptr<TrackedCallback> callback) = 0;
44   virtual int32_t FinishStreamingToFile(
45       scoped_refptr<TrackedCallback> callback) = 0;
46   virtual void Close() = 0;
47
48   // Trusted API.
49   virtual void GrantUniversalAccess() = 0;
50   virtual void RegisterStatusCallback(
51       PP_URLLoaderTrusted_StatusCallback cb) = 0;
52 };
53
54 }  // namespace thunk
55 }  // namespace ppapi
56
57 #endif  // PPAPI_THUNK_URL_LOADER_API_H_