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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc

Issue 2516513002: Lazily create PPDCache directory on first store. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chromeos/printing/ppd_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 } // namespace 77 } // namespace
78 78
79 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui) 79 CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
80 : printer_discoverer_(nullptr), 80 : printer_discoverer_(nullptr),
81 profile_(Profile::FromWebUI(webui)), 81 profile_(Profile::FromWebUI(webui)),
82 weak_factory_(this) { 82 weak_factory_(this) {
83 base::FilePath ppd_cache_path = 83 base::FilePath ppd_cache_path =
84 profile_->GetPath().Append(FILE_PATH_LITERAL("PPDCache")); 84 profile_->GetPath().Append(FILE_PATH_LITERAL("PPDCache"));
85 if (!base::PathExists(ppd_cache_path) &&
86 !base::CreateDirectory(ppd_cache_path)) {
87 LOG(ERROR) << "Failed to create ppd cache directory "
88 << ppd_cache_path.MaybeAsASCII();
89 }
90 ppd_provider_ = chromeos::printing::PpdProvider::Create( 85 ppd_provider_ = chromeos::printing::PpdProvider::Create(
91 google_apis::GetAPIKey(), g_browser_process->system_request_context(), 86 google_apis::GetAPIKey(), g_browser_process->system_request_context(),
92 content::BrowserThread::GetTaskRunnerForThread( 87 content::BrowserThread::GetTaskRunnerForThread(
93 content::BrowserThread::FILE), 88 content::BrowserThread::FILE),
94 chromeos::printing::PpdCache::Create(ppd_cache_path)); 89 chromeos::printing::PpdCache::Create(ppd_cache_path));
95 } 90 }
96 91
97 CupsPrintersHandler::~CupsPrintersHandler() {} 92 CupsPrintersHandler::~CupsPrintersHandler() {}
98 93
99 void CupsPrintersHandler::RegisterMessages() { 94 void CupsPrintersHandler::RegisterMessages() {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 *printers_list); 386 *printers_list);
392 } 387 }
393 388
394 void CupsPrintersHandler::OnDiscoveryDone() { 389 void CupsPrintersHandler::OnDiscoveryDone() {
395 CallJavascriptFunction("cr.webUIListenerCallback", 390 CallJavascriptFunction("cr.webUIListenerCallback",
396 base::StringValue("on-printer-discovery-done")); 391 base::StringValue("on-printer-discovery-done"));
397 } 392 }
398 393
399 } // namespace settings 394 } // namespace settings
400 } // namespace chromeos 395 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/printing/ppd_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698