Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: chrome/service/cloud_print/cloud_print_proxy_backend.h

Issue 1900033005: Simplify some CloudPrintProxy code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 virtual void OnPrintSystemUnavailable() = 0; 43 virtual void OnPrintSystemUnavailable() = 0;
44 // Receive auth token and list of printers. 44 // Receive auth token and list of printers.
45 virtual void OnUnregisterPrinters( 45 virtual void OnUnregisterPrinters(
46 const std::string& auth_token, 46 const std::string& auth_token,
47 const std::list<std::string>& printer_ids) = 0; 47 const std::list<std::string>& printer_ids) = 0;
48 // Update and store service settings. 48 // Update and store service settings.
49 virtual void OnXmppPingUpdated(int ping_timeout) = 0; 49 virtual void OnXmppPingUpdated(int ping_timeout) = 0;
50 50
51 protected: 51 protected:
52 // Don't delete through SyncFrontend interface. 52 // Don't delete through SyncFrontend interface.
53 virtual ~CloudPrintProxyFrontend() { 53 virtual ~CloudPrintProxyFrontend() {}
54 } 54
55 private: 55 private:
56 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyFrontend); 56 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyFrontend);
57 }; 57 };
58 58
59 class CloudPrintProxyBackend { 59 class CloudPrintProxyBackend {
60 public: 60 public:
61 // It is OK for print_system_settings to be NULL. In this case system should
62 // use system default settings.
63 CloudPrintProxyBackend(CloudPrintProxyFrontend* frontend, 61 CloudPrintProxyBackend(CloudPrintProxyFrontend* frontend,
64 const ConnectorSettings& settings, 62 const ConnectorSettings& settings,
65 const gaia::OAuthClientInfo& oauth_client_info, 63 const gaia::OAuthClientInfo& oauth_client_info,
66 bool enable_job_poll); 64 bool enable_job_poll);
67 ~CloudPrintProxyBackend(); 65 ~CloudPrintProxyBackend();
68 66
69 // Legacy mechanism when we have saved user credentials but no saved robot 67 // Legacy mechanism when we have saved user credentials but no saved robot
70 // credentials. 68 // credentials.
71 bool InitializeWithToken(const std::string& cloud_print_token); 69 bool InitializeWithToken(const std::string& cloud_print_token);
72 // Called when we have saved robot credentials. 70 // Called when we have saved robot credentials.
73 bool InitializeWithRobotToken(const std::string& robot_oauth_refresh_token, 71 bool InitializeWithRobotToken(const std::string& robot_oauth_refresh_token,
74 const std::string& robot_email); 72 const std::string& robot_email);
75 // Called when an external entity passed in the auth code for the robot. 73 // Called when an external entity passed in the auth code for the robot.
76 bool InitializeWithRobotAuthCode(const std::string& robot_oauth_auth_code, 74 bool InitializeWithRobotAuthCode(const std::string& robot_oauth_auth_code,
77 const std::string& robot_email); 75 const std::string& robot_email);
78 void Shutdown(); 76 void Shutdown();
79 void RegisterPrinters(const printing::PrinterList& printer_list); 77 void RegisterPrinters(const printing::PrinterList& printer_list);
80 void UnregisterPrinters(); 78 void UnregisterPrinters();
81 79
82 private: 80 private:
81 bool PostCoreTask(const tracked_objects::Location& from_here,
82 const base::Closure& task);
83
83 // The real guts of SyncBackendHost, to keep the public client API clean. 84 // The real guts of SyncBackendHost, to keep the public client API clean.
84 class Core; 85 class Core;
85 // A thread we dedicate for use to perform initialization and 86
86 // authentication. 87 // A thread dedicated for use to perform initialization and authentication.
87 base::Thread core_thread_; 88 base::Thread core_thread_;
88 // Our core, which communicates with AuthWatcher for GAIA authentication and 89
90 // The core, which communicates with AuthWatcher for GAIA authentication and
89 // which contains printer registration code. 91 // which contains printer registration code.
90 scoped_refptr<Core> core_; 92 scoped_refptr<Core> core_;
93
91 // A reference to the MessageLoop used to construct |this|, so we know how 94 // A reference to the MessageLoop used to construct |this|, so we know how
92 // to safely talk back to the SyncFrontend. 95 // to safely talk back to the SyncFrontend.
93 base::MessageLoop* const frontend_loop_; 96 base::MessageLoop* const frontend_loop_;
94 // The frontend which is responsible for displaying UI and updating Prefs 97
95 CloudPrintProxyFrontend* frontend_; 98 // The frontend which is responsible for displaying UI and updating Prefs.
99 // Outlives this backend.
100 CloudPrintProxyFrontend* const frontend_;
96 101
97 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>; 102 friend class base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>;
98 103
99 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend); 104 DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend);
100 }; 105 };
101 106
102 } // namespace cloud_print 107 } // namespace cloud_print
103 108
104 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_ 109 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy.cc ('k') | chrome/service/cloud_print/cloud_print_proxy_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698