| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_ | 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "google_apis/gaia/oauth2_token_service.h" | 11 #include "google_apis/gaia/oauth2_token_service.h" |
| 12 #include "net/url_request/url_fetcher.h" | 12 #include "net/url_request/url_fetcher.h" |
| 13 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
| 14 | 14 |
| 15 namespace local_discovery { | 15 namespace cloud_print { |
| 16 | 16 |
| 17 // API flow for communicating with cloud print and cloud devices. | 17 // API flow for communicating with cloud print and cloud devices. |
| 18 class GCDApiFlow { | 18 class GCDApiFlow { |
| 19 public: | 19 public: |
| 20 // TODO(noamsml): Better error model for this class. | 20 // TODO(noamsml): Better error model for this class. |
| 21 enum Status { | 21 enum Status { |
| 22 SUCCESS, | 22 SUCCESS, |
| 23 ERROR_TOKEN, | 23 ERROR_TOKEN, |
| 24 ERROR_NETWORK, | 24 ERROR_NETWORK, |
| 25 ERROR_HTTP_CODE, | 25 ERROR_HTTP_CODE, |
| 26 ERROR_FROM_SERVER, | 26 ERROR_FROM_SERVER, |
| 27 ERROR_MALFORMED_RESPONSE | 27 ERROR_MALFORMED_RESPONSE |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Provides GCDApiFlowImpl with parameters required to make request. | 30 // Provides GCDApiFlowImpl with parameters required to make request. |
| 31 // Parses results of requests. | 31 // Parses results of requests. |
| 32 class Request { | 32 class Request { |
| 33 public: | 33 public: |
| 34 Request(); | 34 Request(); |
| 35 virtual ~Request(); | 35 virtual ~Request(); |
| 36 | 36 |
| 37 virtual void OnGCDAPIFlowError(Status status) = 0; | 37 virtual void OnGCDApiFlowError(Status status) = 0; |
| 38 | 38 |
| 39 virtual void OnGCDAPIFlowComplete(const base::DictionaryValue& value) = 0; | 39 virtual void OnGCDApiFlowComplete(const base::DictionaryValue& value) = 0; |
| 40 | 40 |
| 41 virtual GURL GetURL() = 0; | 41 virtual GURL GetURL() = 0; |
| 42 | 42 |
| 43 virtual std::string GetOAuthScope() = 0; | 43 virtual std::string GetOAuthScope() = 0; |
| 44 | 44 |
| 45 virtual net::URLFetcher::RequestType GetRequestType(); | 45 virtual net::URLFetcher::RequestType GetRequestType(); |
| 46 | 46 |
| 47 virtual std::vector<std::string> GetExtraRequestHeaders() = 0; | 47 virtual std::vector<std::string> GetExtraRequestHeaders() = 0; |
| 48 | 48 |
| 49 // If there is no data, set upload_type and upload_data to "" | 49 // If there is no data, set upload_type and upload_data to "" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ~CloudPrintApiFlowRequest() override; | 87 ~CloudPrintApiFlowRequest() override; |
| 88 | 88 |
| 89 // GCDApiFlowRequest implementation | 89 // GCDApiFlowRequest implementation |
| 90 std::string GetOAuthScope() override; | 90 std::string GetOAuthScope() override; |
| 91 std::vector<std::string> GetExtraRequestHeaders() override; | 91 std::vector<std::string> GetExtraRequestHeaders() override; |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(CloudPrintApiFlowRequest); | 94 DISALLOW_COPY_AND_ASSIGN(CloudPrintApiFlowRequest); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace local_discovery | 97 } // namespace cloud_print |
| 98 | 98 |
| 99 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_ | 99 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_GCD_API_FLOW_H_ |
| OLD | NEW |