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

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

Issue 2539383002: Replace base::File wrapping with typemapping. (Closed)
Patch Set: Created 4 years 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_service_thread.h" 5 #include "components/font_service/public/cpp/font_service_thread.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "components/font_service/public/cpp/mapped_font_file.h" 12 #include "components/font_service/public/cpp/mapped_font_file.h"
13 #include "mojo/public/cpp/system/platform_handle.h"
14 13
15 namespace font_service { 14 namespace font_service {
16 namespace internal { 15 namespace internal {
17 16
18 namespace { 17 namespace {
19 const char kFontThreadName[] = "Font_Proxy_Thread"; 18 const char kFontThreadName[] = "Font_Proxy_Thread";
20 } // namespace 19 } // namespace
21 20
22 FontServiceThread::FontServiceThread(mojom::FontServicePtr font_service) 21 FontServiceThread::FontServiceThread(mojom::FontServicePtr font_service)
23 : base::Thread(kFontThreadName), 22 : base::Thread(kFontThreadName),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 150 }
152 151
153 pending_waitable_events_.insert(done_event); 152 pending_waitable_events_.insert(done_event);
154 font_service_->OpenStream( 153 font_service_->OpenStream(
155 id_number, base::Bind(&FontServiceThread::OnOpenStreamComplete, this, 154 id_number, base::Bind(&FontServiceThread::OnOpenStreamComplete, this,
156 done_event, output_file)); 155 done_event, output_file));
157 } 156 }
158 157
159 void FontServiceThread::OnOpenStreamComplete(base::WaitableEvent* done_event, 158 void FontServiceThread::OnOpenStreamComplete(base::WaitableEvent* done_event,
160 base::File* output_file, 159 base::File* output_file,
161 mojo::ScopedHandle handle) { 160 base::File file) {
162 pending_waitable_events_.erase(done_event); 161 pending_waitable_events_.erase(done_event);
163 if (handle.is_valid()) { 162 *output_file = std::move(file);
164 base::PlatformFile platform_file;
165 CHECK_EQ(mojo::UnwrapPlatformFile(std::move(handle), &platform_file),
166 MOJO_RESULT_OK);
167 *output_file = base::File(platform_file);
168 }
169
170 done_event->Signal(); 163 done_event->Signal();
171 } 164 }
172 165
173 void FontServiceThread::OnFontServiceConnectionError() { 166 void FontServiceThread::OnFontServiceConnectionError() {
174 std::set<base::WaitableEvent*> events; 167 std::set<base::WaitableEvent*> events;
175 events.swap(pending_waitable_events_); 168 events.swap(pending_waitable_events_);
176 for (base::WaitableEvent* event : events) 169 for (base::WaitableEvent* event : events)
177 event->Signal(); 170 event->Signal();
178 } 171 }
179 172
180 void FontServiceThread::Init() { 173 void FontServiceThread::Init() {
181 font_service_.Bind(std::move(font_service_info_)); 174 font_service_.Bind(std::move(font_service_info_));
182 font_service_.set_connection_error_handler( 175 font_service_.set_connection_error_handler(
183 base::Bind(&FontServiceThread::OnFontServiceConnectionError, 176 base::Bind(&FontServiceThread::OnFontServiceConnectionError,
184 weak_factory_.GetWeakPtr())); 177 weak_factory_.GetWeakPtr()));
185 } 178 }
186 179
187 void FontServiceThread::CleanUp() { 180 void FontServiceThread::CleanUp() {
188 font_service_.reset(); 181 font_service_.reset();
189 } 182 }
190 183
191 } // namespace internal 184 } // namespace internal
192 } // namespace font_service 185 } // namespace font_service
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698