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

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

Issue 10909244: PPAPI: Get TrackedCallback ready for running on non-main threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged. Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/proxy/flash_device_id_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/file_chooser_resource.h" 5 #include "ppapi/proxy/file_chooser_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Convert each of the passed in file infos to resources. These will be 111 // Convert each of the passed in file infos to resources. These will be
112 // owned by the FileChooser object until they're passed to the plugin. 112 // owned by the FileChooser object until they're passed to the plugin.
113 DCHECK(file_queue_.empty()); 113 DCHECK(file_queue_.empty());
114 for (size_t i = 0; i < chosen_files.size(); i++) { 114 for (size_t i = 0; i < chosen_files.size(); i++) {
115 file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef( 115 file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef(
116 chosen_files[i])); 116 chosen_files[i]));
117 } 117 }
118 } 118 }
119 119
120 // Notify the plugin of the new data. 120 // Notify the plugin of the new data.
121 TrackedCallback::ClearAndRun(&callback_, params.result()); 121 callback_->Run(params.result());
122 // DANGER: May delete |this|! 122 // DANGER: May delete |this|!
123 } 123 }
124 124
125 int32_t FileChooserResource::ShowInternal( 125 int32_t FileChooserResource::ShowInternal(
126 PP_Bool save_as, 126 PP_Bool save_as,
127 const PP_Var& suggested_file_name, 127 const PP_Var& suggested_file_name,
128 scoped_refptr<TrackedCallback> callback) { 128 scoped_refptr<TrackedCallback> callback) {
129 if (TrackedCallback::IsPending(callback_)) 129 if (TrackedCallback::IsPending(callback_))
130 return PP_ERROR_INPROGRESS; 130 return PP_ERROR_INPROGRESS;
131 131
132 if (!sent_create_to_renderer()) 132 if (!sent_create_to_renderer())
133 SendCreate(RENDERER, PpapiHostMsg_FileChooser_Create()); 133 SendCreate(RENDERER, PpapiHostMsg_FileChooser_Create());
134 134
135 callback_ = callback; 135 callback_ = callback;
136 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name); 136 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name);
137 137
138 PpapiHostMsg_FileChooser_Show msg( 138 PpapiHostMsg_FileChooser_Show msg(
139 PP_ToBool(save_as), 139 PP_ToBool(save_as),
140 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, 140 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE,
141 sugg_str ? sugg_str->value() : std::string(), 141 sugg_str ? sugg_str->value() : std::string(),
142 accept_types_); 142 accept_types_);
143 Call<PpapiPluginMsg_FileChooser_ShowReply>(RENDERER, msg, 143 Call<PpapiPluginMsg_FileChooser_ShowReply>(RENDERER, msg,
144 base::Bind(&FileChooserResource::OnPluginMsgShowReply, this)); 144 base::Bind(&FileChooserResource::OnPluginMsgShowReply, this));
145 return PP_OK_COMPLETIONPENDING; 145 return PP_OK_COMPLETIONPENDING;
146 } 146 }
147 147
148 } // namespace proxy 148 } // namespace proxy
149 } // namespace ppapi 149 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | ppapi/proxy/flash_device_id_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698