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

Side by Side Diff: components/font_service/public/cpp/font_loader.cc

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/font_service/public/cpp/font_loader.h" 5 #include "components/font_service/public/cpp/font_loader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "components/font_service/public/cpp/font_service_thread.h" 11 #include "components/font_service/public/cpp/font_service_thread.h"
12 #include "mojo/shell/public/cpp/application_impl.h" 12 #include "mojo/shell/public/cpp/shell.h"
13 #include "mojo/shell/public/cpp/connect.h"
14 #include "mojo/shell/public/interfaces/shell.mojom.h"
15 13
16 namespace font_service { 14 namespace font_service {
17 namespace {
18 void OnGotRemoteIDs(uint32_t instance_id, uint32_t content_handler_id) {}
19 } // namespace
20 15
21 FontLoader::FontLoader(mojo::shell::mojom::Shell* shell) { 16 FontLoader::FontLoader(mojo::Shell* shell) {
22 mojo::ServiceProviderPtr font_service_provider;
23 mojo::URLRequestPtr request(mojo::URLRequest::New());
24 request->url = mojo::String::From("mojo:font_service");
25 FontServicePtr font_service; 17 FontServicePtr font_service;
26 shell->ConnectToApplication(std::move(request), 18 shell->ConnectToService("mojo:font_service", &font_service);
27 GetProxy(&font_service_provider), nullptr,
28 mojo::CreatePermissiveCapabilityFilter(),
29 base::Bind(&OnGotRemoteIDs));
30 mojo::ConnectToService(font_service_provider.get(), &font_service);
31
32 thread_ = new internal::FontServiceThread(std::move(font_service)); 19 thread_ = new internal::FontServiceThread(std::move(font_service));
33 } 20 }
34 21
35 FontLoader::FontLoader(mojo::ApplicationImpl* application_impl) {
36 FontServicePtr font_service;
37 application_impl->ConnectToService("mojo:font_service", &font_service);
38
39 thread_ = new internal::FontServiceThread(std::move(font_service));
40 }
41
42 FontLoader::~FontLoader() {} 22 FontLoader::~FontLoader() {}
43 23
44 void FontLoader::Shutdown() { 24 void FontLoader::Shutdown() {
45 thread_->Stop(); 25 thread_->Stop();
46 thread_ = nullptr; 26 thread_ = nullptr;
47 } 27 }
48 28
49 bool FontLoader::matchFamilyName(const char family_name[], 29 bool FontLoader::matchFamilyName(const char family_name[],
50 SkTypeface::Style requested, 30 SkTypeface::Style requested,
51 FontIdentity* out_font_identifier, 31 FontIdentity* out_font_identifier,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 67 }
88 68
89 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) { 69 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) {
90 TRACE_EVENT1("font_loader", "FontLoader::OnMappedFontFileDestroyed", 70 TRACE_EVENT1("font_loader", "FontLoader::OnMappedFontFileDestroyed",
91 "identity", f->font_id()); 71 "identity", f->font_id());
92 base::AutoLock lock(lock_); 72 base::AutoLock lock(lock_);
93 mapped_font_files_.erase(f->font_id()); 73 mapped_font_files_.erase(f->font_id());
94 } 74 }
95 75
96 } // namespace font_service 76 } // namespace font_service
OLDNEW
« no previous file with comments | « components/font_service/public/cpp/font_loader.h ('k') | components/html_viewer/ax_provider_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698