OLD | NEW |
(Empty) | |
| 1 // Copyright 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 CHROME_BROWSER_CHROME_TO_MOBILE_COMMON_CLOUD_PRINT_REQUEST_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROME_TO_MOBILE_COMMON_CLOUD_PRINT_REQUEST_IMPL_H_ |
| 7 |
| 8 #include "chrome/browser/chrome_to_mobile/common/cloud_print_request.h" |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 |
| 14 class GURL; |
| 15 |
| 16 namespace chrome_to_mobile { |
| 17 |
| 18 // An implementation of |CloudPrintRequest|. |
| 19 class CloudPrintRequestImpl : public CloudPrintRequest { |
| 20 public: |
| 21 // Contructs a cloud print request at |url| with the request headers required |
| 22 // by cloud print server and |additional_header|. The request is of type |
| 23 // |request_type|; if it is a POST request, mime type and post data |
| 24 // are given by |post_data_mime_type| and |post_data|. Additional settings are |
| 25 // given in |setting|. |delegate| will be called back when the request |
| 26 // completes. |
| 27 CloudPrintRequestImpl( |
| 28 const GURL& url, |
| 29 const std::string& additional_header, |
| 30 const net::URLFetcher::RequestType& request_type, |
| 31 const std::string& post_data_mime_type, |
| 32 const std::string& post_data, |
| 33 const Settings& setting, |
| 34 Delegate* delegate); |
| 35 virtual ~CloudPrintRequestImpl(); |
| 36 |
| 37 // Starts the request. |
| 38 void Start(); |
| 39 |
| 40 // |CloudPrintRequest| |
| 41 virtual bool HasOAuth2AccessTokenFailure() const OVERRIDE; |
| 42 virtual bool HasCloudPrintAuthError() const OVERRIDE; |
| 43 virtual std::string GetResponseMimeType() const OVERRIDE; |
| 44 virtual std::string GetResponseData(bool* success) const OVERRIDE; |
| 45 |
| 46 protected: |
| 47 // Called back by |fetcher_|. |
| 48 void OnGetOAuth2AccessTokenFailure(); |
| 49 virtual void OnFetchComplete(const net::URLFetcher* source); |
| 50 |
| 51 private: |
| 52 class Fetcher; |
| 53 friend Fetcher; |
| 54 |
| 55 const Settings settings_; |
| 56 Delegate* const delegate_; |
| 57 |
| 58 scoped_ptr<Fetcher> fetcher_; |
| 59 bool auth_token_failure_; |
| 60 }; |
| 61 |
| 62 } // namespace chrome_to_mobile |
| 63 |
| 64 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_COMMON_CLOUD_PRINT_REQUEST_IMPL_H_ |
OLD | NEW |