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

Side by Side Diff: content/browser/font_access/font_access_service_impl.h

Issue 1615133002: Implement API for accessing fonts installed locally on the system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Nasko. Created 4 years, 10 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
« no previous file with comments | « no previous file | content/browser/font_access/font_access_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/font_access/font_getter.h"
13 #include "content/common/font_access/font_access_service.mojom.h"
14 #include "mojo/public/cpp/bindings/strong_binding.h"
15
16 namespace content {
17
18 class FontAccessServiceImpl : public FontAccessService {
19 public:
20 FontAccessServiceImpl(base::Callback<scoped_ptr<FontCacheMap>(void)> getter,
21 mojo::InterfaceRequest<FontAccessService> request);
22 ~FontAccessServiceImpl() override;
23
24 static void Create(mojo::InterfaceRequest<FontAccessService> request);
25
26 // Returns a list of FontAccessDescriptions to the callback.
27 void GetFontList(const GetFontListCallback& callback) override;
28
29 // Returns a Mojo SharedBuffer of the font's binary on the callback.
30 void GetFontData(const mojo::String& family,
31 const mojo::String& style,
32 const GetFontDataCallback& callback) override;
33
34 private:
35 // Used to pass around all the information about a blob from disk.
36 struct BlobInfo {
37 BlobInfo();
38 ~BlobInfo();
39
40 uint64_t size;
41 base::Time last_modified;
42 std::string mime;
43 bool is_valid;
44 };
45
46 static BlobInfo GetFileInfo(const base::FilePath& path);
47
48 // Returns a shared buffer with the binary data from a file path.
49 static mojo::ScopedSharedBufferHandle GetSharedBuffer(
50 const base::FilePath& path,
51 uint64_t size);
52 static void PassBufferAndSize(
53 const FontAccessService::GetFontDataCallback& callback,
54 uint64_t size,
55 mojo::ScopedSharedBufferHandle handle);
56
57 // Clobbers the cache and then fetches the font list.
58 void GetFontListFromCache(const GetFontListCallback& callback);
59
60 // Pulls the font binary path from the cache and returns the font binary in a
61 // shared buffer on the callback, if it exists. If it does not exist, returns
62 // an empty shared buffer on the callback.
63 void GetFontDataInternal(const std::string& family,
64 const std::string& style,
65 const GetFontDataCallback& callback);
66
67 // Returns the font binary path if it exists in the cache.
68 // Otherwise, returns an empty string.
69 base::FilePath FindPathInCache(const std::string& family,
70 const std::string& style);
71
72 void GetFileDataCallback(
73 const FontAccessService::GetFontDataCallback& callback,
74 const base::FilePath& path,
75 const BlobInfo info);
76
77 void ClobberCacheAndReply(const base::Closure closure);
78 void SwapCacheAndReply(const base::Closure closure, scoped_ptr<FontCacheMap>);
79
80 scoped_ptr<FontCacheMap> font_cache_map_;
81 // The binding between this object and the other end of the pipe.
82 mojo::StrongBinding<FontAccessService> binding_;
83 base::Callback<scoped_ptr<FontCacheMap>(void)> cache_map_getter_;
84 base::WeakPtrFactory<FontAccessServiceImpl> weak_factory_;
85
86 DISALLOW_COPY_AND_ASSIGN(FontAccessServiceImpl);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/font_access/font_access_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698