| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ | 5 #ifndef CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ |
| 6 #define CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ | 6 #define CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Use for erasing instance of CloudPrintRequest class. | 31 // Use for erasing instance of CloudPrintRequest class. |
| 32 virtual void OnFetchError(const std::string& server_api, | 32 virtual void OnFetchError(const std::string& server_api, |
| 33 int server_code, | 33 int server_code, |
| 34 int server_http_code) = 0; | 34 int server_http_code) = 0; |
| 35 | 35 |
| 36 // Invoked when timeout is reached. | 36 // Invoked when timeout is reached. |
| 37 // Use for erasing instance of CloudPrintRequest class. | 37 // Use for erasing instance of CloudPrintRequest class. |
| 38 virtual void OnFetchTimeoutReached() = 0; | 38 virtual void OnFetchTimeoutReached() = 0; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 virtual ~CloudPrintRequest(); | 41 ~CloudPrintRequest() override; |
| 42 | 42 |
| 43 // Creates GET request. | 43 // Creates GET request. |
| 44 static scoped_ptr<CloudPrintRequest> CreateGet(const GURL& url, | 44 static scoped_ptr<CloudPrintRequest> CreateGet(const GURL& url, |
| 45 Delegate* delegate); | 45 Delegate* delegate); |
| 46 | 46 |
| 47 // Creates POST request. | 47 // Creates POST request. |
| 48 static scoped_ptr<CloudPrintRequest> CreatePost(const GURL& url, | 48 static scoped_ptr<CloudPrintRequest> CreatePost(const GURL& url, |
| 49 const std::string& content, | 49 const std::string& content, |
| 50 const std::string& mimetype, | 50 const std::string& mimetype, |
| 51 Delegate* delegate); | 51 Delegate* delegate); |
| 52 | 52 |
| 53 // Starts request. Once fetch was completed, parser will be called. | 53 // Starts request. Once fetch was completed, parser will be called. |
| 54 void Run(const std::string& access_token, | 54 void Run(const std::string& access_token, |
| 55 scoped_refptr<net::URLRequestContextGetter> context_getter); | 55 scoped_refptr<net::URLRequestContextGetter> context_getter); |
| 56 | 56 |
| 57 // Add header to request. | 57 // Add header to request. |
| 58 void AddHeader(const std::string& header); | 58 void AddHeader(const std::string& header); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 CloudPrintRequest(const GURL& url, | 61 CloudPrintRequest(const GURL& url, |
| 62 net::URLFetcher::RequestType method, | 62 net::URLFetcher::RequestType method, |
| 63 Delegate* delegate); | 63 Delegate* delegate); |
| 64 | 64 |
| 65 // net::URLFetcherDelegate methods: | 65 // net::URLFetcherDelegate methods: |
| 66 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 66 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 67 | 67 |
| 68 // Method for handling timeout. | 68 // Method for handling timeout. |
| 69 void OnRequestTimeout(); | 69 void OnRequestTimeout(); |
| 70 | 70 |
| 71 scoped_ptr<net::URLFetcher> fetcher_; | 71 scoped_ptr<net::URLFetcher> fetcher_; |
| 72 | 72 |
| 73 Delegate* delegate_; | 73 Delegate* delegate_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(CloudPrintRequest); | 75 DISALLOW_COPY_AND_ASSIGN(CloudPrintRequest); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ | 78 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_CLOUD_PRINT_REQUEST_H_ |
| 79 | 79 |
| OLD | NEW |