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

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

Issue 10065040: RefCounted types should not have public destructors, chrome/ remaining parts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation fixes Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_CONNECTOR_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 21 matching lines...) Expand all
32 public: 32 public:
33 virtual void OnAuthFailed() = 0; 33 virtual void OnAuthFailed() = 0;
34 protected: 34 protected:
35 virtual ~Client() {} 35 virtual ~Client() {}
36 }; 36 };
37 37
38 CloudPrintConnector(Client* client, 38 CloudPrintConnector(Client* client,
39 const std::string& proxy_id, 39 const std::string& proxy_id,
40 const GURL& cloud_print_server_url, 40 const GURL& cloud_print_server_url,
41 const DictionaryValue* print_system_settings); 41 const DictionaryValue* print_system_settings);
42 virtual ~CloudPrintConnector();
43 42
44 bool Start(); 43 bool Start();
45 void Stop(); 44 void Stop();
46 bool IsRunning(); 45 bool IsRunning();
47 46
48 // Register printer from the list. 47 // Register printer from the list.
49 void RegisterPrinters(const printing::PrinterList& printers); 48 void RegisterPrinters(const printing::PrinterList& printers);
50 49
51 // Check for jobs for specific printer. If printer id is empty 50 // Check for jobs for specific printer. If printer id is empty
52 // jobs will be checked for all available printers. 51 // jobs will be checked for all available printers.
53 void CheckForJobs(const std::string& reason, const std::string& printer_id); 52 void CheckForJobs(const std::string& reason, const std::string& printer_id);
54 53
55 // cloud_print::PrintServerWatcherDelegate implementation 54 // cloud_print::PrintServerWatcherDelegate implementation
56 virtual void OnPrinterAdded() OVERRIDE; 55 virtual void OnPrinterAdded() OVERRIDE;
57 // PrinterJobHandler::Delegate implementation 56 // PrinterJobHandler::Delegate implementation
58 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE; 57 virtual void OnPrinterDeleted(const std::string& printer_name) OVERRIDE;
59 virtual void OnAuthError() OVERRIDE; 58 virtual void OnAuthError() OVERRIDE;
60 59
61 // CloudPrintURLFetcher::Delegate implementation. 60 // CloudPrintURLFetcher::Delegate implementation.
62 virtual CloudPrintURLFetcher::ResponseAction HandleRawData( 61 virtual CloudPrintURLFetcher::ResponseAction HandleRawData(
63 const content::URLFetcher* source, 62 const content::URLFetcher* source,
64 const GURL& url, 63 const GURL& url,
65 const std::string& data) OVERRIDE; 64 const std::string& data) OVERRIDE;
66
67 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData( 65 virtual CloudPrintURLFetcher::ResponseAction HandleJSONData(
68 const content::URLFetcher* source, 66 const content::URLFetcher* source,
69 const GURL& url, 67 const GURL& url,
70 base::DictionaryValue* json_data, 68 base::DictionaryValue* json_data,
71 bool succeeded) OVERRIDE; 69 bool succeeded) OVERRIDE;
72 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE; 70 virtual CloudPrintURLFetcher::ResponseAction OnRequestAuthError() OVERRIDE;
73 virtual std::string GetAuthHeader() OVERRIDE; 71 virtual std::string GetAuthHeader() OVERRIDE;
74 72
75 private: 73 private:
74 friend class base::RefCountedThreadSafe<CloudPrintConnector>;
75
76 // Prototype for a response handler. 76 // Prototype for a response handler.
77 typedef CloudPrintURLFetcher::ResponseAction 77 typedef CloudPrintURLFetcher::ResponseAction
78 (CloudPrintConnector::*ResponseHandler)( 78 (CloudPrintConnector::*ResponseHandler)(
79 const content::URLFetcher* source, 79 const content::URLFetcher* source,
80 const GURL& url, 80 const GURL& url,
81 DictionaryValue* json_data, 81 DictionaryValue* json_data,
82 bool succeeded); 82 bool succeeded);
83 83
84 enum PendingTaskType {
85 PENDING_PRINTERS_NONE,
86 PENDING_PRINTERS_AVAILABLE,
87 PENDING_PRINTER_REGISTER,
88 PENDING_PRINTER_DELETE
89 };
90
91 // TODO(jhawkins): This name conflicts with base::PendingTask.
92 struct PendingTask {
93 PendingTaskType type;
94 // Optional members, depending on type.
95 std::string printer_id; // For pending delete.
96 printing::PrinterBasicInfo printer_info; // For pending registration.
97
98 PendingTask() : type(PENDING_PRINTERS_NONE) {}
99 ~PendingTask() {}
100 };
101
102 virtual ~CloudPrintConnector();
103
84 // Begin response handlers 104 // Begin response handlers
85 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse( 105 CloudPrintURLFetcher::ResponseAction HandlePrinterListResponse(
86 const content::URLFetcher* source, 106 const content::URLFetcher* source,
87 const GURL& url, 107 const GURL& url,
88 DictionaryValue* json_data, 108 DictionaryValue* json_data,
89 bool succeeded); 109 bool succeeded);
90 110
91 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse( 111 CloudPrintURLFetcher::ResponseAction HandlePrinterDeleteResponse(
92 const content::URLFetcher* source, 112 const content::URLFetcher* source,
93 const GURL& url, 113 const GURL& url,
(...skipping 19 matching lines...) Expand all
113 133
114 // Reports a diagnostic message to the server. 134 // Reports a diagnostic message to the server.
115 void ReportUserMessage(const std::string& message_id, 135 void ReportUserMessage(const std::string& message_id,
116 const std::string& failure_message); 136 const std::string& failure_message);
117 137
118 bool RemovePrinterFromList(const std::string& printer_name, 138 bool RemovePrinterFromList(const std::string& printer_name,
119 printing::PrinterList* printer_list); 139 printing::PrinterList* printer_list);
120 140
121 void InitJobHandlerForPrinter(DictionaryValue* printer_data); 141 void InitJobHandlerForPrinter(DictionaryValue* printer_data);
122 142
123 enum PendingTaskType {
124 PENDING_PRINTERS_NONE,
125 PENDING_PRINTERS_AVAILABLE,
126 PENDING_PRINTER_REGISTER,
127 PENDING_PRINTER_DELETE
128 };
129
130 // TODO(jhawkins): This name conflicts with base::PendingTask.
131 struct PendingTask {
132 PendingTaskType type;
133 // Optional members, depending on type.
134 std::string printer_id; // For pending delete.
135 printing::PrinterBasicInfo printer_info; // For pending registration.
136
137 PendingTask() : type(PENDING_PRINTERS_NONE) {}
138 ~PendingTask() {}
139 };
140
141 void AddPendingAvailableTask(); 143 void AddPendingAvailableTask();
142 void AddPendingDeleteTask(const std::string& id); 144 void AddPendingDeleteTask(const std::string& id);
143 void AddPendingRegisterTask(const printing::PrinterBasicInfo& info); 145 void AddPendingRegisterTask(const printing::PrinterBasicInfo& info);
144 void AddPendingTask(const PendingTask& task); 146 void AddPendingTask(const PendingTask& task);
145 void ProcessPendingTask(); 147 void ProcessPendingTask();
146 void ContinuePendingTaskProcessing(); 148 void ContinuePendingTaskProcessing();
147 void OnPrintersAvailable(); 149 void OnPrintersAvailable();
148 void OnPrinterRegister(const printing::PrinterBasicInfo& info); 150 void OnPrinterRegister(const printing::PrinterBasicInfo& info);
149 void OnPrinterDelete(const std::string& name); 151 void OnPrinterDelete(const std::string& name);
150 152
(...skipping 28 matching lines...) Expand all
179 // The CloudPrintURLFetcher instance for the current request. 181 // The CloudPrintURLFetcher instance for the current request.
180 scoped_refptr<CloudPrintURLFetcher> request_; 182 scoped_refptr<CloudPrintURLFetcher> request_;
181 // The CloudPrintURLFetcher instance for the user message request. 183 // The CloudPrintURLFetcher instance for the user message request.
182 scoped_refptr<CloudPrintURLFetcher> user_message_request_; 184 scoped_refptr<CloudPrintURLFetcher> user_message_request_;
183 185
184 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector); 186 DISALLOW_COPY_AND_ASSIGN(CloudPrintConnector);
185 }; 187 };
186 188
187 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_ 189 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONNECTOR_H_
188 190
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698