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

Side by Side Diff: printing/backend/print_backend_cups.cc

Issue 5682008: Make members of Singleton<T> private and only visible to the singleton type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 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 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 #include "printing/backend/print_backend.h" 5 #include "printing/backend/print_backend.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #if !defined(OS_MACOSX) 9 #if !defined(OS_MACOSX)
10 #include <gcrypt.h> 10 #include <gcrypt.h>
11 #endif 11 #endif
12 #include <pthread.h> 12 #include <pthread.h>
13 13
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/lazy_instance.h"
15 #include "base/lock.h" 16 #include "base/lock.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/singleton.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "printing/backend/cups_helper.h" 21 #include "printing/backend/cups_helper.h"
22 22
23 #if !defined(OS_MACOSX) 23 #if !defined(OS_MACOSX)
24 GCRY_THREAD_OPTION_PTHREAD_IMPL; 24 GCRY_THREAD_OPTION_PTHREAD_IMPL;
25 25
26 namespace { 26 namespace {
27 27
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (!pgnutls_global_init) { 59 if (!pgnutls_global_init) {
60 LOG(ERROR) << "Could not find " << kGnuTlsInitFuncName 60 LOG(ERROR) << "Could not find " << kGnuTlsInitFuncName
61 << " in " << kGnuTlsFile; 61 << " in " << kGnuTlsFile;
62 return; 62 return;
63 } 63 }
64 if ((*pgnutls_global_init)() != 0) 64 if ((*pgnutls_global_init)() != 0)
65 LOG(ERROR) << "Gnutls initialization failed"; 65 LOG(ERROR) << "Gnutls initialization failed";
66 } 66 }
67 }; 67 };
68 68
69 static base::LazyInstance<GcryptInitializer> g_gcrypt_initializer(
70 base::LINKER_INITIALIZED);
71
69 } // namespace 72 } // namespace
70 #endif 73 #endif
71 74
72 namespace printing { 75 namespace printing {
73 76
74 static const char kCUPSPrinterInfoOpt[] = "printer-info"; 77 static const char kCUPSPrinterInfoOpt[] = "printer-info";
75 static const char kCUPSPrinterStateOpt[] = "printer-state"; 78 static const char kCUPSPrinterStateOpt[] = "printer-state";
76 static const char kCUPSPrintServerURL[] = "print_server_url"; 79 static const char kCUPSPrintServerURL[] = "print_server_url";
77 80
78 class PrintBackendCUPS : public PrintBackend { 81 class PrintBackendCUPS : public PrintBackend {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 for (it = printer_list.begin(); it != printer_list.end(); ++it) 184 for (it = printer_list.begin(); it != printer_list.end(); ++it)
182 if (it->printer_name == printer_name) 185 if (it->printer_name == printer_name)
183 return true; 186 return true;
184 return false; 187 return false;
185 } 188 }
186 189
187 scoped_refptr<PrintBackend> PrintBackend::CreateInstance( 190 scoped_refptr<PrintBackend> PrintBackend::CreateInstance(
188 const DictionaryValue* print_backend_settings) { 191 const DictionaryValue* print_backend_settings) {
189 #if !defined(OS_MACOSX) 192 #if !defined(OS_MACOSX)
190 // Initialize gcrypt library. 193 // Initialize gcrypt library.
191 Singleton<GcryptInitializer>::get(); 194 g_gcrypt_initializer.Get();
192 #endif 195 #endif
193 196
194 std::string print_server_url_str; 197 std::string print_server_url_str;
195 if (print_backend_settings) { 198 if (print_backend_settings) {
196 print_backend_settings->GetString(kCUPSPrintServerURL, 199 print_backend_settings->GetString(kCUPSPrintServerURL,
197 &print_server_url_str); 200 &print_server_url_str);
198 } 201 }
199 GURL print_server_url(print_server_url_str.c_str()); 202 GURL print_server_url(print_server_url_str.c_str());
200 return new PrintBackendCUPS(print_server_url); 203 return new PrintBackendCUPS(print_server_url);
201 } 204 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 << ", content length: " << content_len; 253 << ", content length: " << content_len;
251 file_util::Delete(ppd_path, false); 254 file_util::Delete(ppd_path, false);
252 ppd_path.clear(); 255 ppd_path.clear();
253 } 256 }
254 } 257 }
255 } 258 }
256 return ppd_path; 259 return ppd_path;
257 } 260 }
258 261
259 } // namespace printing 262 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698