|
| 1 | +// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved. |
| 2 | +// License: New BSD License. |
| 3 | +// Website: http://code.google.com/p/cefpython/ |
| 4 | + |
| 5 | +#pragma once |
| 6 | + |
| 7 | +#if defined(_WIN32) |
| 8 | +#include "../windows/stdint.h" |
| 9 | +#endif |
| 10 | + |
| 11 | +#include "cefpython_public_api.h" |
| 12 | + |
| 13 | +class WebRequestClient : public CefURLRequestClient |
| 14 | +{ |
| 15 | +public: |
| 16 | + int webRequestId_; |
| 17 | +public: |
| 18 | + WebRequestClient(int webRequestId) : |
| 19 | + webRequestId_(webRequestId) { |
| 20 | + } |
| 21 | + virtual ~WebRequestClient(){} |
| 22 | + |
| 23 | + /// |
| 24 | + // Interface that should be implemented by the CefURLRequest client. The |
| 25 | + // methods of this class will be called on the same thread that created the |
| 26 | + // request. |
| 27 | + /// |
| 28 | + |
| 29 | + /// |
| 30 | + // Notifies the client that the request has completed. Use the |
| 31 | + // CefURLRequest::GetRequestStatus method to determine if the request was |
| 32 | + // successful or not. |
| 33 | + /// |
| 34 | + /*--cef()--*/ |
| 35 | + virtual void OnRequestComplete(CefRefPtr<CefURLRequest> request) OVERRIDE; |
| 36 | + |
| 37 | + /// |
| 38 | + // Notifies the client of upload progress. |current| denotes the number of |
| 39 | + // bytes sent so far and |total| is the total size of uploading data (or -1 if |
| 40 | + // chunked upload is enabled). This method will only be called if the |
| 41 | + // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. |
| 42 | + /// |
| 43 | + /*--cef()--*/ |
| 44 | + virtual void OnUploadProgress(CefRefPtr<CefURLRequest> request, |
| 45 | + uint64 current, |
| 46 | + uint64 total) OVERRIDE; |
| 47 | + |
| 48 | + /// |
| 49 | + // Notifies the client of download progress. |current| denotes the number of |
| 50 | + // bytes received up to the call and |total| is the expected total size of the |
| 51 | + // response (or -1 if not determined). |
| 52 | + /// |
| 53 | + /*--cef()--*/ |
| 54 | + virtual void OnDownloadProgress(CefRefPtr<CefURLRequest> request, |
| 55 | + uint64 current, |
| 56 | + uint64 total) OVERRIDE; |
| 57 | + |
| 58 | + /// |
| 59 | + // Called when some part of the response is read. |data| contains the current |
| 60 | + // bytes received since the last call. This method will not be called if the |
| 61 | + // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. |
| 62 | + /// |
| 63 | + /*--cef()--*/ |
| 64 | + virtual void OnDownloadData(CefRefPtr<CefURLRequest> request, |
| 65 | + const void* data, |
| 66 | + size_t data_length) OVERRIDE; |
| 67 | + |
| 68 | +protected: |
| 69 | + // Include the default reference counting implementation. |
| 70 | + IMPLEMENT_REFCOUNTING(WebRequestClient); |
| 71 | +}; |
0 commit comments