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

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

Issue 2476073003: Update PpdProvider threading model. (Closed)
Patch Set: Change CHECK to DCHECK 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chromeos/printing/ppd_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
index 4eb854f2edc073adcd9fd65a3e10d71fb32906ca..7fa0ec816499ca64023b59d09c73501a845ba260 100644
--- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -11,6 +11,7 @@
#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/printing/printer_pref_manager_factory.h"
@@ -83,6 +84,8 @@ CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
base::PathService::Get(chrome::DIR_CHROMEOS_PPD_CACHE, &ppd_cache_path));
ppd_provider_ = chromeos::printing::PpdProvider::Create(
google_apis::GetAPIKey(), g_browser_process->system_request_context(),
+ content::BrowserThread::GetTaskRunnerForThread(
+ content::BrowserThread::FILE),
chromeos::printing::PpdCache::Create(ppd_cache_path));
}
@@ -268,9 +271,20 @@ void CupsPrintersHandler::HandleGetCupsPrinterModels(
CHECK_EQ(2U, args->GetSize());
CHECK(args->GetString(0, &js_callback));
CHECK(args->GetString(1, &manufacturer));
- ppd_provider_->QueryAvailable(
- base::Bind(&CupsPrintersHandler::QueryAvailableModelsDone,
- weak_factory_.GetWeakPtr(), js_callback, manufacturer));
+ // Special case the "asked with no manufacturer case" since the UI sometimes
+ // triggers this and it should yield a trivial (empty) result
+ if (manufacturer.empty()) {
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&CupsPrintersHandler::QueryAvailableModelsDone,
+ weak_factory_.GetWeakPtr(), js_callback, manufacturer,
+ chromeos::printing::PpdProvider::SUCCESS,
+ chromeos::printing::PpdProvider::AvailablePrintersMap()));
+ } else {
+ ppd_provider_->QueryAvailable(
+ base::Bind(&CupsPrintersHandler::QueryAvailableModelsDone,
+ weak_factory_.GetWeakPtr(), js_callback, manufacturer));
+ }
}
void CupsPrintersHandler::HandleSelectPPDFile(const base::ListValue* args) {
« no previous file with comments | « no previous file | chromeos/printing/ppd_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698