OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include "base/thread.h" |
| 12 #include "chrome/browser/net/url_fetcher.h" |
| 13 #include "chrome/browser/printing/cloud_print/printer_info.h" |
| 14 |
| 15 class CloudPrintProxyService; |
| 16 class DictionaryValue; |
| 17 |
| 18 // CloudPrintProxyFrontend is the interface used by CloudPrintProxyBackend to |
| 19 // communicate with the entity that created it and, presumably, is interested in |
| 20 // cloud print proxy related activity. |
| 21 // NOTE: All methods will be invoked by a CloudPrintProxyBackend on the same |
| 22 // thread used to create that CloudPrintProxyBackend. |
| 23 class CloudPrintProxyFrontend { |
| 24 public: |
| 25 CloudPrintProxyFrontend() {} |
| 26 |
| 27 // There is a list of printers available that can be registered. |
| 28 virtual void OnPrinterListAvailable( |
| 29 const cloud_print::PrinterList& printer_list) = 0; |
| 30 |
| 31 protected: |
| 32 // Don't delete through SyncFrontend interface. |
| 33 virtual ~CloudPrintProxyFrontend() { |
| 34 } |
| 35 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyFrontend); |
| 37 }; |
| 38 |
| 39 class CloudPrintProxyBackend { |
| 40 public: |
| 41 explicit CloudPrintProxyBackend(CloudPrintProxyFrontend* frontend); |
| 42 ~CloudPrintProxyBackend(); |
| 43 |
| 44 bool Initialize(const std::string& auth_token, const std::string& proxy_id); |
| 45 void Shutdown(); |
| 46 void RegisterPrinters(const cloud_print::PrinterList& printer_list); |
| 47 void HandlePrinterNotification(const std::string& printer_id); |
| 48 |
| 49 private: |
| 50 // The real guts of SyncBackendHost, to keep the public client API clean. |
| 51 class Core; |
| 52 // A thread we dedicate for use to perform initialization and |
| 53 // authentication. |
| 54 base::Thread core_thread_; |
| 55 // Our core, which communicates with AuthWatcher for GAIA authentication and |
| 56 // which contains printer registration code. |
| 57 scoped_refptr<Core> core_; |
| 58 // A reference to the MessageLoop used to construct |this|, so we know how |
| 59 // to safely talk back to the SyncFrontend. |
| 60 MessageLoop* const frontend_loop_; |
| 61 // The frontend which is responsible for displaying UI and updating Prefs |
| 62 CloudPrintProxyFrontend* frontend_; |
| 63 |
| 64 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); |
| 67 }; |
| 68 |
| 69 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ |
| 70 |
OLD | NEW |