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

Side by Side Diff: chromeos/printing/ppd_cache.h

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 #ifndef CHROMEOS_PRINTING_PPD_CACHE_H_ 5 #ifndef CHROMEOS_PRINTING_PPD_CACHE_H_
6 #define CHROMEOS_PRINTING_PPD_CACHE_H_ 6 #define CHROMEOS_PRINTING_PPD_CACHE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/sequenced_task_runner.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
17 16
18 namespace chromeos { 17 namespace chromeos {
19 namespace printing { 18 namespace printing {
20 19
21 // PpdCache manages a cache of locally-stored PPD files. At its core, it 20 // PpdCache manages a cache of locally-stored PPD files. At its core, it
22 // operates like a persistent hash from PpdReference to files. If you give the 21 // operates like a persistent hash from PpdReference to files. If you give the
23 // same PpdReference to Find() that was previously given to store, you should 22 // same PpdReference to Find() that was previously given to store, you should
24 // get the same FilePath back out (unless the previous entry has timed out of 23 // get the same FilePath back out (unless the previous entry has timed out of
(...skipping 14 matching lines...) Expand all
39 38
40 // Contents of the entry. 39 // Contents of the entry.
41 std::string contents; 40 std::string contents;
42 }; 41 };
43 42
44 using FindCallback = base::Callback<void(const FindResult& result)>; 43 using FindCallback = base::Callback<void(const FindResult& result)>;
45 44
46 // Create and return a Ppdcache that uses cache_dir to store state. If 45 // Create and return a Ppdcache that uses cache_dir to store state. If
47 // cache_base_dir does not exist, it will be lazily created the first time the 46 // cache_base_dir does not exist, it will be lazily created the first time the
48 // cache needs to store state. 47 // cache needs to store state.
49 static scoped_refptr<PpdCache> Create( 48 static scoped_refptr<PpdCache> Create(const base::FilePath& cache_base_dir);
50 const base::FilePath& cache_base_dir,
51 scoped_refptr<base::SequencedTaskRunner> disk_task_runner);
52 49
53 // Start a Find, looking, for an entry with the given key that is at most 50 // Start a Find, looking, for an entry with the given key that is at most
54 // |max_age| old. |cb| will be invoked on the calling thread. 51 // |max_age| old. |cb| will be invoked on the calling thread.
55 virtual void Find(const std::string& key, const FindCallback& cb) = 0; 52 virtual void Find(const std::string& key, const FindCallback& cb) = 0;
56 53
57 // Store the given contents at the given key. If cb is non-null, it will 54 // Store the given contents at the given key. If cb is non-null, it will
58 // be invoked on completion. 55 // be invoked on completion.
59 virtual void Store(const std::string& key, 56 virtual void Store(const std::string& key,
60 const std::string& contents, 57 const std::string& contents,
61 const base::Callback<void()>& cb) = 0; 58 const base::Callback<void()>& cb) = 0;
62 59
63 // Hook for testing. Returns true if all outstanding cache operations 60 // Hook for testing. Returns true if all outstanding cache operations
64 // are complete. 61 // are complete.
65 virtual bool Idle() const = 0; 62 virtual bool Idle() const = 0;
66 63
67 protected: 64 protected:
68 friend class base::RefCounted<PpdCache>; 65 friend class base::RefCounted<PpdCache>;
69 virtual ~PpdCache() {} 66 virtual ~PpdCache() {}
70 }; 67 };
71 68
72 } // namespace printing 69 } // namespace printing
73 } // namespace chromeos 70 } // namespace chromeos
74 71
75 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_ 72 #endif // CHROMEOS_PRINTING_PPD_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698