summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_file_chooser_impl.h
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-04 23:00:11 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-04 23:00:11 +0000
commit3087191f1a992007de8f930ab477e4aa36ff52d0 (patch)
treee188de0a681288d1c5341337f63f82f02335583d /webkit/plugins/ppapi/ppb_file_chooser_impl.h
parent0464e16a54318266b7b7710b2af9484701f93320 (diff)
downloadchromium_src-3087191f1a992007de8f930ab477e4aa36ff52d0.zip
chromium_src-3087191f1a992007de8f930ab477e4aa36ff52d0.tar.gz
chromium_src-3087191f1a992007de8f930ab477e4aa36ff52d0.tar.bz2
Pepper: Fix a pile of bugs in the implementation of the file chooser API.
This fixes: - a crash, due to holding a plain old pointer to a ref-counted object; - a DCHECK() failure, due to using FilePath::AppendASCII(); - incorrect/non-handling of PP_ERROR_INPROGRESS; - non-initialization of PPB_FileChooser_Impl::next_chosen_file_index_; - non-clearing of PPB_FileChooser_Impl::chosen_files_ upon Show() being called (e.g., a second time); - not aborting callbacks on resource deletion. Probably something else too. BUG=none TEST=Trung is a bit happier Review URL: http://codereview.chromium.org/6334117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_file_chooser_impl.h')
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.h b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
index 1d4c7de..93004d0 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,17 +8,18 @@
#include <string>
#include <vector>
-#include "base/scoped_ptr.h"
+#include "base/ref_counted.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
#include "webkit/plugins/ppapi/resource.h"
+struct PP_CompletionCallback;
+
namespace webkit {
namespace ppapi {
-class PluginDelegate;
class PluginInstance;
class PPB_FileRef_Impl;
+class TrackedCompletionCallback;
class PPB_FileChooser_Impl : public Resource {
public:
@@ -36,14 +37,25 @@ class PPB_FileChooser_Impl : public Resource {
// Stores the list of selected files.
void StoreChosenFiles(const std::vector<std::string>& files);
+ // Check that |callback| is valid (only non-blocking operation is supported)
+ // and that no callback is already pending. Returns |PP_OK| if okay, else
+ // |PP_ERROR_...| to be returned to the plugin.
+ int32_t ValidateCallback(const PP_CompletionCallback& callback);
+
+ // Sets up |callback| as the pending callback. This should only be called once
+ // it is certain that |PP_ERROR_WOULDBLOCK| will be returned.
+ void RegisterCallback(const PP_CompletionCallback& callback);
+
+ void RunCallback(int32_t result);
+
// PPB_FileChooser implementation.
- int32_t Show(PP_CompletionCallback callback);
+ int32_t Show(const PP_CompletionCallback& callback);
scoped_refptr<PPB_FileRef_Impl> GetNextChosenFile();
private:
PP_FileChooserMode_Dev mode_;
std::string accept_mime_types_;
- PP_CompletionCallback completion_callback_;
+ scoped_refptr<TrackedCompletionCallback> callback_;
std::vector< scoped_refptr<PPB_FileRef_Impl> > chosen_files_;
size_t next_chosen_file_index_;
};