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

Side by Side Diff: chromeos/printing/ppd_provider.cc

Issue 2939373003: Convert PpdCache and PpdProvider to TaskScheduler. (Closed)
Patch Set: remove extra imports Created 3 years, 6 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
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 "chromeos/printing/ppd_provider.h" 5 #include "chromeos/printing/ppd_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/base64.h" 14 #include "base/base64.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/files/file.h" 16 #include "base/files/file.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/json/json_parser.h" 18 #include "base/json/json_parser.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "base/sequenced_task_runner.h"
20 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_split.h" 22 #include "base/strings/string_split.h"
22 #include "base/strings/string_tokenizer.h" 23 #include "base/strings/string_tokenizer.h"
23 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
25 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
26 #include "base/task_runner_util.h" 27 #include "base/task_runner_util.h"
28 #include "base/task_scheduler/post_task.h"
27 #include "base/threading/sequenced_task_runner_handle.h" 29 #include "base/threading/sequenced_task_runner_handle.h"
28 #include "base/threading/thread_restrictions.h" 30 #include "base/threading/thread_restrictions.h"
29 #include "base/time/time.h" 31 #include "base/time/time.h"
30 #include "base/values.h" 32 #include "base/values.h"
31 #include "chromeos/printing/ppd_cache.h" 33 #include "chromeos/printing/ppd_cache.h"
32 #include "chromeos/printing/printing_constants.h" 34 #include "chromeos/printing/printing_constants.h"
33 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
34 #include "net/http/http_status_code.h" 36 #include "net/http/http_status_code.h"
35 #include "net/url_request/url_fetcher.h" 37 #include "net/url_request/url_fetcher.h"
36 #include "net/url_request/url_fetcher_delegate.h" 38 #include "net/url_request/url_fetcher_delegate.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 FT_PRINTERS, // List of printers from a manufacturer. 196 FT_PRINTERS, // List of printers from a manufacturer.
195 FT_PPD_INDEX, // Master ppd index. 197 FT_PPD_INDEX, // Master ppd index.
196 FT_PPD, // A Ppd file. 198 FT_PPD, // A Ppd file.
197 FT_USB_DEVICES // USB device id to canonical name map. 199 FT_USB_DEVICES // USB device id to canonical name map.
198 }; 200 };
199 201
200 PpdProviderImpl( 202 PpdProviderImpl(
201 const std::string& browser_locale, 203 const std::string& browser_locale,
202 scoped_refptr<net::URLRequestContextGetter> url_context_getter, 204 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
203 scoped_refptr<PpdCache> ppd_cache, 205 scoped_refptr<PpdCache> ppd_cache,
204 scoped_refptr<base::SequencedTaskRunner> disk_task_runner,
205 const PpdProvider::Options& options) 206 const PpdProvider::Options& options)
206 : browser_locale_(browser_locale), 207 : browser_locale_(browser_locale),
207 url_context_getter_(url_context_getter), 208 url_context_getter_(url_context_getter),
208 ppd_cache_(ppd_cache), 209 ppd_cache_(ppd_cache),
209 disk_task_runner_(disk_task_runner), 210 disk_task_runner_(base::CreateSequencedTaskRunnerWithTraits(
211 {base::TaskPriority::USER_BLOCKING,
gab 2017/06/19 15:13:22 Are you sure this is USER_BLOCKING? It was previou
skau 2017/06/19 23:31:08 No. This should have been USER_VISIBLE. It is no
212 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})),
210 options_(options), 213 options_(options),
211 weak_factory_(this) {} 214 weak_factory_(this) {}
212 215
213 // Resolving manufacturers requires a couple of steps, because of 216 // Resolving manufacturers requires a couple of steps, because of
214 // localization. First we have to figure out what locale to use, which 217 // localization. First we have to figure out what locale to use, which
215 // involves grabbing a list of available locales from the server. Once we 218 // involves grabbing a list of available locales from the server. Once we
216 // have decided on a locale, we go out and fetch the manufacturers map in that 219 // have decided on a locale, we go out and fetch the manufacturers map in that
217 // localization. 220 // localization.
218 // 221 //
219 // This means when a request comes in, we either queue it and start background 222 // This means when a request comes in, we either queue it and start background
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 ~PpdProviderImpl() override {} 997 ~PpdProviderImpl() override {}
995 }; 998 };
996 999
997 } // namespace 1000 } // namespace
998 1001
999 // static 1002 // static
1000 scoped_refptr<PpdProvider> PpdProvider::Create( 1003 scoped_refptr<PpdProvider> PpdProvider::Create(
1001 const std::string& browser_locale, 1004 const std::string& browser_locale,
1002 scoped_refptr<net::URLRequestContextGetter> url_context_getter, 1005 scoped_refptr<net::URLRequestContextGetter> url_context_getter,
1003 scoped_refptr<PpdCache> ppd_cache, 1006 scoped_refptr<PpdCache> ppd_cache,
1004 scoped_refptr<base::SequencedTaskRunner> disk_task_runner,
1005 const PpdProvider::Options& options) { 1007 const PpdProvider::Options& options) {
1006 return scoped_refptr<PpdProvider>( 1008 return scoped_refptr<PpdProvider>(new PpdProviderImpl(
1007 new PpdProviderImpl(browser_locale, url_context_getter, ppd_cache, 1009 browser_locale, url_context_getter, ppd_cache, options));
1008 disk_task_runner, options));
1009 } 1010 }
1010 } // namespace printing 1011 } // namespace printing
1011 } // namespace chromeos 1012 } // namespace chromeos
OLDNEW
« chromeos/printing/ppd_cache.cc ('K') | « chromeos/printing/ppd_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698