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

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: merge Created 8 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 | Annotate | Revision Log
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/string_split.h" 7 #include "base/string_split.h"
8 #include "ipc/ipc_message.h" 8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/dispatch_reply_message.h" 10 #include "ppapi/proxy/dispatch_reply_message.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Convert each of the passed in file infos to resources. These will be 119 // Convert each of the passed in file infos to resources. These will be
120 // owned by the FileChooser object until they're passed to the plugin. 120 // owned by the FileChooser object until they're passed to the plugin.
121 DCHECK(file_queue_.empty()); 121 DCHECK(file_queue_.empty());
122 for (size_t i = 0; i < chosen_files.size(); i++) { 122 for (size_t i = 0; i < chosen_files.size(); i++) {
123 file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef( 123 file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef(
124 chosen_files[i])); 124 chosen_files[i]));
125 } 125 }
126 } 126 }
127 127
128 // Notify the plugin of the new data. 128 // Notify the plugin of the new data.
129 TrackedCallback::ClearAndRun(&callback_, params.result()); 129 callback_->Run(params.result());
viettrungluu 2012/09/25 00:18:11 I don't see how you can leave the value of |callba
dmichael (off chromium) 2012/10/24 21:40:52 IsPending(callback_) will return false if: callbac
130 // DANGER: May delete |this|! 130 // DANGER: May delete |this|!
131 } 131 }
132 132
133 int32_t FileChooserResource::ShowInternal( 133 int32_t FileChooserResource::ShowInternal(
134 PP_Bool save_as, 134 PP_Bool save_as,
135 const PP_Var& suggested_file_name, 135 const PP_Var& suggested_file_name,
136 scoped_refptr<TrackedCallback> callback) { 136 scoped_refptr<TrackedCallback> callback) {
137 if (TrackedCallback::IsPending(callback_)) 137 if (TrackedCallback::IsPending(callback_))
138 return PP_ERROR_INPROGRESS; 138 return PP_ERROR_INPROGRESS;
139 139
140 if (!sent_create_to_renderer()) 140 if (!sent_create_to_renderer())
141 SendCreateToRenderer(PpapiHostMsg_FileChooser_Create()); 141 SendCreateToRenderer(PpapiHostMsg_FileChooser_Create());
142 142
143 callback_ = callback; 143 callback_ = callback;
144 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name); 144 StringVar* sugg_str = StringVar::FromPPVar(suggested_file_name);
145 145
146 CallRenderer(PpapiHostMsg_FileChooser_Show( 146 CallRenderer(PpapiHostMsg_FileChooser_Show(
147 PP_ToBool(save_as), 147 PP_ToBool(save_as),
148 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, 148 mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE,
149 sugg_str ? sugg_str->value() : std::string(), 149 sugg_str ? sugg_str->value() : std::string(),
150 accept_types_)); 150 accept_types_));
151 return PP_OK_COMPLETIONPENDING; 151 return PP_OK_COMPLETIONPENDING;
152 } 152 }
153 153
154 } // namespace proxy 154 } // namespace proxy
155 } // namespace ppapi 155 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | ppapi/proxy/flash_device_id_resource.cc » ('j') | ppapi/shared_impl/tracked_callback.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698