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

Side by Side Diff: chrome/service/cloud_print/print_system.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, 7 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_PRINT_SYSTEM_H_ 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Callback interface for new printer notifications. 77 // Callback interface for new printer notifications.
78 class Delegate { 78 class Delegate {
79 public: 79 public:
80 virtual void OnPrinterAdded() = 0; 80 virtual void OnPrinterAdded() = 0;
81 // TODO(gene): Do we need OnPrinterDeleted notification here? 81 // TODO(gene): Do we need OnPrinterDeleted notification here?
82 82
83 protected: 83 protected:
84 virtual ~Delegate() {} 84 virtual ~Delegate() {}
85 }; 85 };
86 86
87 virtual ~PrintServerWatcher();
88 virtual bool StartWatching(PrintServerWatcher::Delegate* delegate) = 0; 87 virtual bool StartWatching(PrintServerWatcher::Delegate* delegate) = 0;
89 virtual bool StopWatching() = 0; 88 virtual bool StopWatching() = 0;
89
90 protected:
91 friend class base::RefCountedThreadSafe<PrintServerWatcher>;
92 virtual ~PrintServerWatcher();
90 }; 93 };
91 94
92 class PrinterWatcher : public base::RefCountedThreadSafe<PrinterWatcher> { 95 class PrinterWatcher : public base::RefCountedThreadSafe<PrinterWatcher> {
93 public: 96 public:
94 // Callback interface for printer updates notifications. 97 // Callback interface for printer updates notifications.
95 class Delegate { 98 class Delegate {
96 public: 99 public:
97 virtual void OnPrinterDeleted() = 0; 100 virtual void OnPrinterDeleted() = 0;
98 virtual void OnPrinterChanged() = 0; 101 virtual void OnPrinterChanged() = 0;
99 virtual void OnJobChanged() = 0; 102 virtual void OnJobChanged() = 0;
100 103
101 protected: 104 protected:
102 virtual ~Delegate() {} 105 virtual ~Delegate() {}
103 }; 106 };
104 107
105 virtual ~PrinterWatcher();
106 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0; 108 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0;
107 virtual bool StopWatching() = 0; 109 virtual bool StopWatching() = 0;
108 virtual bool GetCurrentPrinterInfo( 110 virtual bool GetCurrentPrinterInfo(
109 printing::PrinterBasicInfo* printer_info) = 0; 111 printing::PrinterBasicInfo* printer_info) = 0;
112
113 protected:
114 friend class base::RefCountedThreadSafe<PrinterWatcher>;
115 virtual ~PrinterWatcher();
110 }; 116 };
111 117
112 class JobSpooler : public base::RefCountedThreadSafe<JobSpooler> { 118 class JobSpooler : public base::RefCountedThreadSafe<JobSpooler> {
113 public: 119 public:
114 // Callback interface for JobSpooler notifications. 120 // Callback interface for JobSpooler notifications.
115 class Delegate { 121 class Delegate {
116 public: 122 public:
117 virtual ~Delegate() { } 123 virtual ~Delegate() { }
118 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) = 0; 124 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) = 0;
119 virtual void OnJobSpoolFailed() = 0; 125 virtual void OnJobSpoolFailed() = 0;
120 }; 126 };
121 127
122 virtual ~JobSpooler();
123 // Spool job to the printer asynchronously. Caller will be notified via 128 // Spool job to the printer asynchronously. Caller will be notified via
124 // |delegate|. Note that only one print job can be in progress at any given 129 // |delegate|. Note that only one print job can be in progress at any given
125 // time. Subsequent calls to Spool (before the Delegate::OnJobSpoolSucceeded 130 // time. Subsequent calls to Spool (before the Delegate::OnJobSpoolSucceeded
126 // or Delegate::OnJobSpoolFailed methods are called) can fail. 131 // or Delegate::OnJobSpoolFailed methods are called) can fail.
127 virtual bool Spool(const std::string& print_ticket, 132 virtual bool Spool(const std::string& print_ticket,
128 const FilePath& print_data_file_path, 133 const FilePath& print_data_file_path,
129 const std::string& print_data_mime_type, 134 const std::string& print_data_mime_type,
130 const std::string& printer_name, 135 const std::string& printer_name,
131 const std::string& job_title, 136 const std::string& job_title,
132 const std::vector<std::string>& tags, 137 const std::vector<std::string>& tags,
133 JobSpooler::Delegate* delegate) = 0; 138 JobSpooler::Delegate* delegate) = 0;
139 protected:
140 friend class base::RefCountedThreadSafe<JobSpooler>;
141 virtual ~JobSpooler();
134 }; 142 };
135 143
136 class PrintSystemResult { 144 class PrintSystemResult {
137 public: 145 public:
138 PrintSystemResult(bool succeeded, const std::string& message) 146 PrintSystemResult(bool succeeded, const std::string& message)
139 : succeeded_(succeeded), message_(message) { } 147 : succeeded_(succeeded), message_(message) { }
140 bool succeeded() const { return succeeded_; } 148 bool succeeded() const { return succeeded_; }
141 std::string message() const { return message_; } 149 std::string message() const { return message_; }
142 150
143 private: 151 private:
152 PrintSystemResult() {}
153
144 bool succeeded_; 154 bool succeeded_;
145 std::string message_; 155 std::string message_;
146
147 PrintSystemResult() { }
148 }; 156 };
149 157
150 typedef base::Callback<void(bool, 158 typedef base::Callback<void(bool,
151 const std::string&, 159 const std::string&,
152 const printing::PrinterCapsAndDefaults&)> 160 const printing::PrinterCapsAndDefaults&)>
153 PrinterCapsAndDefaultsCallback; 161 PrinterCapsAndDefaultsCallback;
154 162
155 virtual ~PrintSystem();
156
157 // Initialize print system. This need to be called before any other function 163 // Initialize print system. This need to be called before any other function
158 // of PrintSystem. 164 // of PrintSystem.
159 virtual PrintSystemResult Init() = 0; 165 virtual PrintSystemResult Init() = 0;
160 166
161 // Enumerates the list of installed local and network printers. 167 // Enumerates the list of installed local and network printers.
162 virtual PrintSystemResult EnumeratePrinters( 168 virtual PrintSystemResult EnumeratePrinters(
163 printing::PrinterList* printer_list) = 0; 169 printing::PrinterList* printer_list) = 0;
164 170
165 // Gets the capabilities and defaults for a specific printer asynchronously. 171 // Gets the capabilities and defaults for a specific printer asynchronously.
166 virtual void GetPrinterCapsAndDefaults( 172 virtual void GetPrinterCapsAndDefaults(
(...skipping 25 matching lines...) Expand all
192 virtual std::string GetSupportedMimeTypes() = 0; 198 virtual std::string GetSupportedMimeTypes() = 0;
193 199
194 // Generate unique for proxy. 200 // Generate unique for proxy.
195 static std::string GenerateProxyId(); 201 static std::string GenerateProxyId();
196 202
197 // Call this function to obtain printing system for specified print server. 203 // Call this function to obtain printing system for specified print server.
198 // If print settings are NULL, default settings will be used. 204 // If print settings are NULL, default settings will be used.
199 // Return NULL if no print system available. 205 // Return NULL if no print system available.
200 static scoped_refptr<PrintSystem> CreateInstance( 206 static scoped_refptr<PrintSystem> CreateInstance(
201 const base::DictionaryValue* print_system_settings); 207 const base::DictionaryValue* print_system_settings);
208
209 protected:
210 friend class base::RefCountedThreadSafe<PrintSystem>;
211 virtual ~PrintSystem();
202 }; 212 };
203 213
204 214
205 // This typedef is to workaround the issue with certain versions of 215 // This typedef is to workaround the issue with certain versions of
206 // Visual Studio where it gets confused between multiple Delegate 216 // Visual Studio where it gets confused between multiple Delegate
207 // classes and gives a C2500 error. (I saw this error on the try bots - 217 // classes and gives a C2500 error. (I saw this error on the try bots -
208 // the workaround was not needed for my machine). 218 // the workaround was not needed for my machine).
209 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate; 219 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate;
210 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate; 220 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate;
211 typedef PrintSystem::JobSpooler::Delegate JobSpoolerDelegate; 221 typedef PrintSystem::JobSpooler::Delegate JobSpoolerDelegate;
212 222
213 } // namespace cloud_print 223 } // namespace cloud_print
214 224
215 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ 225 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698