OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_SERVICE_IMPL_H_ | |
6 #define CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_SERVICE_IMPL_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "content/browser/font_access/font_getter.h" | |
12 #include "content/common/font_access/font_access_service.mojom.h" | |
13 #include "mojo/public/cpp/bindings/strong_binding.h" | |
14 | |
15 namespace content { | |
16 | |
17 class FontAccessServiceImpl : public FontAccessService { | |
18 public: | |
19 FontAccessServiceImpl( | |
20 base::Callback<scoped_ptr<FontCacheMap>(void)> getter, | |
21 mojo::InterfaceRequest<FontAccessService> request); | |
22 ~FontAccessServiceImpl() override; | |
23 | |
24 // Returns a list of FontAccessDescriptions on the callback. | |
25 void GetFontList(const GetFontListCallback& callback) override; | |
26 | |
27 // Returns a Mojo SharedBuffer of the font's binary on the callback. | |
28 void GetFontData(const mojo::String& family, | |
29 const mojo::String& style, | |
30 const GetFontDataCallback& callback) override; | |
31 | |
32 static void Create( | |
33 mojo::InterfaceRequest<FontAccessService> request); | |
34 | |
35 private: | |
36 // Used to pass around all the information about a blob from disk. | |
37 struct BlobInfo { | |
38 BlobInfo(); | |
39 ~BlobInfo(); | |
40 | |
41 uint64_t size; | |
42 base::Time last_modified; | |
43 std::string mime; | |
44 }; | |
mlamouri (slow - plz ping)
2016/01/26 17:17:11
nit: DISALLOW_COPY_AND_ASSIGN?
Daniel Nishi
2016/01/26 18:36:10
I think I use the implicit move, so the macro will
| |
45 | |
46 // Clobbers the cache and then fetches the font list. | |
47 void GetFontListFromCache(const GetFontListCallback& callback); | |
48 | |
49 // Pulls the font binary path from the cache and returns the font binary in a | |
50 // shared buffer on the callback, if it exists. If it does not exist, returns | |
51 // an empty shared buffer on the callback. | |
52 void GetFontDataInternal(const std::string& family, | |
53 const std::string& style, | |
54 const GetFontDataCallback& callback); | |
55 // Returns the font binary path if it exists in the cache. | |
56 // Otherwise, returns an empty string. | |
57 const std::string FindPathInCache(const std::string family, | |
58 const std::string style); | |
mlamouri (slow - plz ping)
2016/01/26 17:17:11
const std::string&?
Daniel Nishi
2016/01/26 18:36:10
Done.
| |
59 | |
60 void GetFileDataCallback( | |
61 const FontAccessService::GetFontDataCallback& callback, | |
62 const std::string path, | |
mlamouri (slow - plz ping)
2016/01/26 17:17:11
ditto
Daniel Nishi
2016/01/26 18:36:10
Done.
| |
63 const BlobInfo info); | |
64 | |
65 void ClobberCacheAndReply(const base::Closure closure); | |
66 void SwapCacheAndReply(const base::Closure closure, scoped_ptr<FontCacheMap>); | |
67 | |
68 static BlobInfo GetFileInfo(const std::string path); | |
69 | |
70 // Returns a shared buffer with the binary data from a file path. | |
71 static mojo::ScopedSharedBufferHandle GetSharedBuffer(const std::string path, | |
72 uint64_t size); | |
73 static void PassBufferAndSize( | |
74 const FontAccessService::GetFontDataCallback& callback, | |
75 uint64_t size, | |
76 mojo::ScopedSharedBufferHandle handle); | |
77 | |
78 scoped_ptr<FontCacheMap> font_cache_map_; | |
79 // The binding between this object and the other end of the pipe. | |
80 mojo::StrongBinding<FontAccessService> binding_; | |
81 base::Callback<scoped_ptr<FontCacheMap>(void)> cache_map_getter_; | |
82 base::WeakPtrFactory<FontAccessServiceImpl> weak_factory_; | |
83 }; | |
mlamouri (slow - plz ping)
2016/01/26 17:17:11
DISALLOW_COPY_AND_ASSIGN.
Daniel Nishi
2016/01/26 18:36:10
Done.
| |
84 } | |
mlamouri (slow - plz ping)
2016/01/26 17:17:11
nit: leave a blank line before and add ` // names
Daniel Nishi
2016/01/26 18:36:10
Done.
| |
85 | |
86 #endif | |
OLD | NEW |