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

Side by Side Diff: ppapi/proxy/flash_font_file_resource.cc

Issue 1147883002: Cleanup some PPAPI proxy code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SIZE_MAX Created 5 years, 7 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 | « ppapi/proxy/flash_font_file_resource.h ('k') | ppapi/proxy/pdf_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/proxy/flash_font_file_resource.h" 5 #include "ppapi/proxy/flash_font_file_resource.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "ppapi/c/dev/ppb_font_dev.h" 9 #include "ppapi/c/dev/ppb_font_dev.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 24 matching lines...) Expand all
35 void* output, 35 void* output,
36 uint32_t* output_length) { 36 uint32_t* output_length) {
37 if (!output_length) 37 if (!output_length)
38 return PP_FALSE; 38 return PP_FALSE;
39 39
40 if (!sent_create_to_renderer()) { 40 if (!sent_create_to_renderer()) {
41 SendCreate( 41 SendCreate(
42 RENDERER, PpapiHostMsg_FlashFontFile_Create(description_, charset_)); 42 RENDERER, PpapiHostMsg_FlashFontFile_Create(description_, charset_));
43 } 43 }
44 44
45 std::string* contents = GetFontTable(table); 45 const std::string* contents = GetFontTable(table);
46 if (!contents) { 46 if (!contents) {
47 std::string out_contents; 47 std::string out_contents;
48 int32_t result = SyncCall<PpapiPluginMsg_FlashFontFile_GetFontTableReply>( 48 int32_t result = SyncCall<PpapiPluginMsg_FlashFontFile_GetFontTableReply>(
49 RENDERER, PpapiHostMsg_FlashFontFile_GetFontTable(table), 49 RENDERER, PpapiHostMsg_FlashFontFile_GetFontTable(table),
50 &out_contents); 50 &out_contents);
51 if (result != PP_OK) 51 if (result != PP_OK)
52 return PP_FALSE; 52 return PP_FALSE;
53 53
54 contents = AddFontTable(table, out_contents); 54 contents = AddFontTable(table, out_contents);
55 } 55 }
56 56
57 // If we are going to copy the data into |output|, it must be big enough. 57 // If we are going to copy the data into |output|, it must be big enough.
58 if (output && *output_length < contents->size()) 58 if (output && *output_length < contents->size())
59 return PP_FALSE; 59 return PP_FALSE;
60 60
61 *output_length = static_cast<uint32_t>(contents->size()); 61 *output_length = static_cast<uint32_t>(contents->size());
62 if (output) 62 if (output)
63 memcpy(output, contents->c_str(), *output_length); 63 memcpy(output, contents->c_str(), *output_length);
64 return PP_TRUE; 64 return PP_TRUE;
65 } 65 }
66 66
67 std::string* FlashFontFileResource::GetFontTable(uint32_t table) const { 67 const std::string* FlashFontFileResource::GetFontTable(uint32_t table) const {
68 FontTableMap::const_iterator found = font_tables_.find(table); 68 FontTableMap::const_iterator found = font_tables_.find(table);
69 if (found == font_tables_.end()) 69 return (found != font_tables_.end()) ? found->second : nullptr;
70 return NULL;
71 return found->second.get();
72 } 70 }
73 71
74 std::string* FlashFontFileResource::AddFontTable(uint32_t table, 72 const std::string* FlashFontFileResource::AddFontTable(
75 const std::string& contents) { 73 uint32_t table,
76 linked_ptr<std::string> heap_string(new std::string(contents)); 74 const std::string& contents) {
77 font_tables_[table] = heap_string; 75 FontTableMap::const_iterator it =
78 return heap_string.get(); 76 font_tables_.set(table, make_scoped_ptr(new std::string(contents)));
77 return it->second;
79 } 78 }
80 79
81 } // namespace proxy 80 } // namespace proxy
82 } // namespace ppapi 81 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/flash_font_file_resource.h ('k') | ppapi/proxy/pdf_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698