| 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 typedef base::Callback<void( | 35 typedef base::Callback<void( |
| 36 const base::DictionaryValue* /*value*/)> ResultCallback; | 36 const base::DictionaryValue* /*value*/)> ResultCallback; |
| 37 | 37 |
| 38 virtual ~PrivetJSONOperation() {} | 38 virtual ~PrivetJSONOperation() {} |
| 39 | 39 |
| 40 virtual void Start() = 0; | 40 virtual void Start() = 0; |
| 41 | 41 |
| 42 virtual PrivetHTTPClient* GetHTTPClient() = 0; | 42 virtual PrivetHTTPClient* GetHTTPClient() = 0; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // Privet HTTP client. Must outlive the operations it creates. |
| 46 class PrivetHTTPClient { |
| 47 public: |
| 48 virtual ~PrivetHTTPClient() {} |
| 49 |
| 50 // A name for the HTTP client, e.g. the device name for the privet device. |
| 51 virtual const std::string& GetName() = 0; |
| 52 |
| 53 // Creates operation to query basic information about local device. |
| 54 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( |
| 55 const PrivetJSONOperation::ResultCallback& callback) = 0; |
| 56 |
| 57 virtual scoped_ptr<PrivetURLFetcher> CreateURLFetcher( |
| 58 const GURL& url, |
| 59 net::URLFetcher::RequestType request_type, |
| 60 PrivetURLFetcher::Delegate* delegate) = 0; |
| 61 |
| 62 virtual void RefreshPrivetToken( |
| 63 const PrivetURLFetcher::TokenCallback& token_callback) = 0; |
| 64 }; |
| 65 |
| 45 class PrivetDataReadOperation { | 66 class PrivetDataReadOperation { |
| 46 public: | 67 public: |
| 47 enum ResponseType { | 68 enum ResponseType { |
| 48 RESPONSE_TYPE_ERROR, | 69 RESPONSE_TYPE_ERROR, |
| 49 RESPONSE_TYPE_STRING, | 70 RESPONSE_TYPE_STRING, |
| 50 RESPONSE_TYPE_FILE | 71 RESPONSE_TYPE_FILE |
| 51 }; | 72 }; |
| 52 | 73 |
| 53 // If value is null, the operation failed. | 74 // If value is null, the operation failed. |
| 54 typedef base::Callback<void( | 75 typedef base::Callback<void( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 virtual void SetPageSize(const gfx::Size& page_size) = 0; | 174 virtual void SetPageSize(const gfx::Size& page_size) = 0; |
| 154 | 175 |
| 155 // For testing, inject an alternative PWG raster converter. | 176 // For testing, inject an alternative PWG raster converter. |
| 156 virtual void SetPWGRasterConverterForTesting( | 177 virtual void SetPWGRasterConverterForTesting( |
| 157 scoped_ptr<PWGRasterConverter> pwg_raster_converter) = 0; | 178 scoped_ptr<PWGRasterConverter> pwg_raster_converter) = 0; |
| 158 | 179 |
| 159 virtual PrivetHTTPClient* GetHTTPClient() = 0; | 180 virtual PrivetHTTPClient* GetHTTPClient() = 0; |
| 160 }; | 181 }; |
| 161 | 182 |
| 162 // Privet HTTP client. Must outlive the operations it creates. | 183 // Privet HTTP client. Must outlive the operations it creates. |
| 163 class PrivetHTTPClient { | 184 class PrivetV1HTTPClient { |
| 164 public: | 185 public: |
| 165 virtual ~PrivetHTTPClient() {} | 186 virtual ~PrivetV1HTTPClient() {} |
| 187 |
| 188 // A name for the HTTP client, e.g. the device name for the privet device. |
| 189 virtual const std::string& GetName() = 0; |
| 190 |
| 191 static scoped_ptr<PrivetV1HTTPClient> CreateDefault( |
| 192 scoped_ptr<PrivetHTTPClient> info_client); |
| 193 |
| 194 // Creates operation to query basic information about local device. |
| 195 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( |
| 196 const PrivetJSONOperation::ResultCallback& callback) = 0; |
| 166 | 197 |
| 167 // Creates operation to register local device using Privet v1 protocol. | 198 // Creates operation to register local device using Privet v1 protocol. |
| 168 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( | 199 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( |
| 169 const std::string& user, | 200 const std::string& user, |
| 170 PrivetRegisterOperation::Delegate* delegate) = 0; | 201 PrivetRegisterOperation::Delegate* delegate) = 0; |
| 171 | 202 |
| 172 // Creates operation to query basic information about local device. | |
| 173 virtual scoped_ptr<PrivetJSONOperation> CreateInfoOperation( | |
| 174 const PrivetJSONOperation::ResultCallback& callback) = 0; | |
| 175 | |
| 176 // Creates operation to query capabilities of local printer. | 203 // Creates operation to query capabilities of local printer. |
| 177 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( | 204 virtual scoped_ptr<PrivetJSONOperation> CreateCapabilitiesOperation( |
| 178 const PrivetJSONOperation::ResultCallback& callback) = 0; | 205 const PrivetJSONOperation::ResultCallback& callback) = 0; |
| 179 | 206 |
| 180 // Creates operation to submit print job to local printer. | 207 // Creates operation to submit print job to local printer. |
| 181 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( | 208 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( |
| 182 PrivetLocalPrintOperation::Delegate* delegate) = 0; | 209 PrivetLocalPrintOperation::Delegate* delegate) = 0; |
| 183 | 210 |
| 184 // Creates operation to list files on local Privet storage. | 211 // Creates operation to list files on local Privet storage. |
| 185 virtual scoped_ptr<PrivetJSONOperation> CreateStorageListOperation( | 212 virtual scoped_ptr<PrivetJSONOperation> CreateStorageListOperation( |
| 186 const std::string& path, | 213 const std::string& path, |
| 187 const PrivetJSONOperation::ResultCallback& callback) = 0; | 214 const PrivetJSONOperation::ResultCallback& callback) = 0; |
| 188 | 215 |
| 189 // Creates operation to read data from local Privet storage. | 216 // Creates operation to read data from local Privet storage. |
| 190 virtual scoped_ptr<PrivetDataReadOperation> CreateStorageReadOperation( | 217 virtual scoped_ptr<PrivetDataReadOperation> CreateStorageReadOperation( |
| 191 const std::string& path, | 218 const std::string& path, |
| 192 const PrivetDataReadOperation::ResultCallback& callback) = 0; | 219 const PrivetDataReadOperation::ResultCallback& callback) = 0; |
| 193 | |
| 194 // A name for the HTTP client, e.g. the device name for the privet device. | |
| 195 virtual const std::string& GetName() = 0; | |
| 196 }; | 220 }; |
| 197 | 221 |
| 198 } // namespace local_discovery | 222 } // namespace local_discovery |
| 199 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 223 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
| OLD | NEW |