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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_truetype_font_host.cc

Issue 501033003: Remove implicit conversions from scoped_refptr to T* in content/browser/renderer_host/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/renderer_host/pepper/pepper_truetype_font_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_truetype_font_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "content/browser/renderer_host/pepper/pepper_truetype_font.h" 10 #include "content/browser/renderer_host/pepper/pepper_truetype_font.h"
(...skipping 19 matching lines...) Expand all
30 initialize_completed_(false), 30 initialize_completed_(false),
31 weak_factory_(this) { 31 weak_factory_(this) {
32 font_ = PepperTrueTypeFont::Create(); 32 font_ = PepperTrueTypeFont::Create();
33 // Initialize the font on a blocking pool thread. This must complete before 33 // Initialize the font on a blocking pool thread. This must complete before
34 // using |font_|. 34 // using |font_|.
35 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 35 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
36 task_runner_ = pool->GetSequencedTaskRunner(pool->GetSequenceToken()); 36 task_runner_ = pool->GetSequencedTaskRunner(pool->GetSequenceToken());
37 SerializedTrueTypeFontDesc* actual_desc = 37 SerializedTrueTypeFontDesc* actual_desc =
38 new SerializedTrueTypeFontDesc(desc); 38 new SerializedTrueTypeFontDesc(desc);
39 base::PostTaskAndReplyWithResult( 39 base::PostTaskAndReplyWithResult(
40 task_runner_, 40 task_runner_.get(),
41 FROM_HERE, 41 FROM_HERE,
42 base::Bind(&PepperTrueTypeFont::Initialize, font_, actual_desc), 42 base::Bind(&PepperTrueTypeFont::Initialize, font_, actual_desc),
43 base::Bind(&PepperTrueTypeFontHost::OnInitializeComplete, 43 base::Bind(&PepperTrueTypeFontHost::OnInitializeComplete,
44 weak_factory_.GetWeakPtr(), 44 weak_factory_.GetWeakPtr(),
45 base::Owned(actual_desc))); 45 base::Owned(actual_desc)));
46 } 46 }
47 47
48 PepperTrueTypeFontHost::~PepperTrueTypeFontHost() { 48 PepperTrueTypeFontHost::~PepperTrueTypeFontHost() {
49 if (font_) { 49 if (font_.get()) {
50 // Release the font on the task runner in case the implementation requires 50 // Release the font on the task runner in case the implementation requires
51 // long blocking operations. 51 // long blocking operations.
52 font_->AddRef(); 52 font_->AddRef();
53 PepperTrueTypeFont* raw_font = font_.get(); 53 PepperTrueTypeFont* raw_font = font_.get();
54 font_ = NULL; 54 font_ = NULL;
55 task_runner_->ReleaseSoon(FROM_HERE, raw_font); 55 task_runner_->ReleaseSoon(FROM_HERE, raw_font);
56 } 56 }
57 } 57 }
58 58
59 int32_t PepperTrueTypeFontHost::OnResourceMessageReceived( 59 int32_t PepperTrueTypeFontHost::OnResourceMessageReceived(
60 const IPC::Message& msg, 60 const IPC::Message& msg,
61 HostMessageContext* context) { 61 HostMessageContext* context) {
62 if (!host()->permissions().HasPermission(ppapi::PERMISSION_DEV)) 62 if (!host()->permissions().HasPermission(ppapi::PERMISSION_DEV))
63 return PP_ERROR_FAILED; 63 return PP_ERROR_FAILED;
64 64
65 PPAPI_BEGIN_MESSAGE_MAP(PepperTrueTypeFontHost, msg) 65 PPAPI_BEGIN_MESSAGE_MAP(PepperTrueTypeFontHost, msg)
66 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_GetTableTags, 66 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TrueTypeFont_GetTableTags,
67 OnHostMsgGetTableTags) 67 OnHostMsgGetTableTags)
68 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TrueTypeFont_GetTable, 68 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TrueTypeFont_GetTable,
69 OnHostMsgGetTable) 69 OnHostMsgGetTable)
70 PPAPI_END_MESSAGE_MAP() 70 PPAPI_END_MESSAGE_MAP()
71 return PP_ERROR_FAILED; 71 return PP_ERROR_FAILED;
72 } 72 }
73 73
74 int32_t PepperTrueTypeFontHost::OnHostMsgGetTableTags( 74 int32_t PepperTrueTypeFontHost::OnHostMsgGetTableTags(
75 HostMessageContext* context) { 75 HostMessageContext* context) {
76 if (!font_) 76 if (!font_.get())
77 return PP_ERROR_FAILED; 77 return PP_ERROR_FAILED;
78 78
79 // Get font data on a thread that allows slow blocking operations. 79 // Get font data on a thread that allows slow blocking operations.
80 std::vector<uint32_t>* tags = new std::vector<uint32_t>(); 80 std::vector<uint32_t>* tags = new std::vector<uint32_t>();
81 base::PostTaskAndReplyWithResult( 81 base::PostTaskAndReplyWithResult(
82 task_runner_, 82 task_runner_.get(),
83 FROM_HERE, 83 FROM_HERE,
84 base::Bind(&PepperTrueTypeFont::GetTableTags, font_, tags), 84 base::Bind(&PepperTrueTypeFont::GetTableTags, font_, tags),
85 base::Bind(&PepperTrueTypeFontHost::OnGetTableTagsComplete, 85 base::Bind(&PepperTrueTypeFontHost::OnGetTableTagsComplete,
86 weak_factory_.GetWeakPtr(), 86 weak_factory_.GetWeakPtr(),
87 base::Owned(tags), 87 base::Owned(tags),
88 context->MakeReplyMessageContext())); 88 context->MakeReplyMessageContext()));
89 89
90 return PP_OK_COMPLETIONPENDING; 90 return PP_OK_COMPLETIONPENDING;
91 } 91 }
92 92
93 int32_t PepperTrueTypeFontHost::OnHostMsgGetTable(HostMessageContext* context, 93 int32_t PepperTrueTypeFontHost::OnHostMsgGetTable(HostMessageContext* context,
94 uint32_t table, 94 uint32_t table,
95 int32_t offset, 95 int32_t offset,
96 int32_t max_data_length) { 96 int32_t max_data_length) {
97 if (!font_) 97 if (!font_.get())
98 return PP_ERROR_FAILED; 98 return PP_ERROR_FAILED;
99 if (offset < 0 || max_data_length < 0) 99 if (offset < 0 || max_data_length < 0)
100 return PP_ERROR_BADARGUMENT; 100 return PP_ERROR_BADARGUMENT;
101 101
102 // Get font data on a thread that allows slow blocking operations. 102 // Get font data on a thread that allows slow blocking operations.
103 std::string* data = new std::string(); 103 std::string* data = new std::string();
104 base::PostTaskAndReplyWithResult( 104 base::PostTaskAndReplyWithResult(
105 task_runner_, 105 task_runner_.get(),
106 FROM_HERE, 106 FROM_HERE,
107 base::Bind(&PepperTrueTypeFont::GetTable, 107 base::Bind(&PepperTrueTypeFont::GetTable,
108 font_, 108 font_,
109 table, 109 table,
110 offset, 110 offset,
111 max_data_length, 111 max_data_length,
112 data), 112 data),
113 base::Bind(&PepperTrueTypeFontHost::OnGetTableComplete, 113 base::Bind(&PepperTrueTypeFontHost::OnGetTableComplete,
114 weak_factory_.GetWeakPtr(), 114 weak_factory_.GetWeakPtr(),
115 base::Owned(data), 115 base::Owned(data),
(...skipping 14 matching lines...) Expand all
130 pp_resource(), PpapiPluginMsg_TrueTypeFont_CreateReply(*desc, result)); 130 pp_resource(), PpapiPluginMsg_TrueTypeFont_CreateReply(*desc, result));
131 } 131 }
132 132
133 void PepperTrueTypeFontHost::OnGetTableTagsComplete( 133 void PepperTrueTypeFontHost::OnGetTableTagsComplete(
134 std::vector<uint32_t>* tags, 134 std::vector<uint32_t>* tags,
135 ReplyMessageContext reply_context, 135 ReplyMessageContext reply_context,
136 int32_t result) { 136 int32_t result) {
137 DCHECK(initialize_completed_); 137 DCHECK(initialize_completed_);
138 // It's possible that Initialize failed and that |font_| is NULL. Check that 138 // It's possible that Initialize failed and that |font_| is NULL. Check that
139 // the font implementation doesn't return PP_OK in that case. 139 // the font implementation doesn't return PP_OK in that case.
140 DCHECK(font_ || result != PP_OK); 140 DCHECK(font_.get() || result != PP_OK);
141 reply_context.params.set_result(result); 141 reply_context.params.set_result(result);
142 host()->SendReply(reply_context, 142 host()->SendReply(reply_context,
143 PpapiPluginMsg_TrueTypeFont_GetTableTagsReply(*tags)); 143 PpapiPluginMsg_TrueTypeFont_GetTableTagsReply(*tags));
144 } 144 }
145 145
146 void PepperTrueTypeFontHost::OnGetTableComplete( 146 void PepperTrueTypeFontHost::OnGetTableComplete(
147 std::string* data, 147 std::string* data,
148 ReplyMessageContext reply_context, 148 ReplyMessageContext reply_context,
149 int32_t result) { 149 int32_t result) {
150 DCHECK(initialize_completed_); 150 DCHECK(initialize_completed_);
151 // It's possible that Initialize failed and that |font_| is NULL. Check that 151 // It's possible that Initialize failed and that |font_| is NULL. Check that
152 // the font implementation doesn't return PP_OK in that case. 152 // the font implementation doesn't return PP_OK in that case.
153 DCHECK(font_ || result != PP_OK); 153 DCHECK(font_.get() || result != PP_OK);
154 reply_context.params.set_result(result); 154 reply_context.params.set_result(result);
155 host()->SendReply(reply_context, 155 host()->SendReply(reply_context,
156 PpapiPluginMsg_TrueTypeFont_GetTableReply(*data)); 156 PpapiPluginMsg_TrueTypeFont_GetTableReply(*data));
157 } 157 }
158 158
159 } // namespace content 159 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698