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

Side by Side Diff: ppapi/thunk/ppb_file_chooser_thunk.cc

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « ppapi/thunk/ppb_directory_reader_thunk.cc ('k') | ppapi/thunk/ppb_file_io_thunk.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/c/dev/ppb_file_chooser_dev.h" 5 #include "ppapi/c/dev/ppb_file_chooser_dev.h"
6 #include "ppapi/c/pp_completion_callback.h" 6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/thunk/common.h"
9 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_file_chooser_api.h" 11 #include "ppapi/thunk/ppb_file_chooser_api.h"
11 #include "ppapi/thunk/resource_creation_api.h" 12 #include "ppapi/thunk/resource_creation_api.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace thunk { 15 namespace thunk {
15 16
16 namespace { 17 namespace {
17 18
18 PP_Resource Create(PP_Instance instance, 19 PP_Resource Create(PP_Instance instance,
19 const PP_FileChooserOptions_Dev* options) { 20 const PP_FileChooserOptions_Dev* options) {
20 EnterFunction<ResourceCreationAPI> enter(instance, true); 21 EnterFunction<ResourceCreationAPI> enter(instance, true);
21 if (enter.failed()) 22 if (enter.failed())
22 return 0; 23 return 0;
23 return enter.functions()->CreateFileChooser(instance, options); 24 return enter.functions()->CreateFileChooser(instance, options);
24 } 25 }
25 26
26 PP_Bool IsFileChooser(PP_Resource resource) { 27 PP_Bool IsFileChooser(PP_Resource resource) {
27 EnterResource<PPB_FileChooser_API> enter(resource, false); 28 EnterResource<PPB_FileChooser_API> enter(resource, false);
28 return PP_FromBool(enter.succeeded()); 29 return PP_FromBool(enter.succeeded());
29 } 30 }
30 31
31 int32_t Show(PP_Resource chooser, PP_CompletionCallback callback) { 32 int32_t Show(PP_Resource chooser, PP_CompletionCallback callback) {
32 EnterResource<PPB_FileChooser_API> enter(chooser, true); 33 EnterResource<PPB_FileChooser_API> enter(chooser, true);
33 if (enter.failed()) 34 if (enter.failed())
34 return PP_ERROR_BADRESOURCE; 35 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
35 return enter.object()->Show(callback); 36 int32_t result = enter.object()->Show(callback);
37 return MayForceCallback(callback, result);
36 } 38 }
37 39
38 PP_Resource GetNextChosenFile(PP_Resource chooser) { 40 PP_Resource GetNextChosenFile(PP_Resource chooser) {
39 EnterResource<PPB_FileChooser_API> enter(chooser, true); 41 EnterResource<PPB_FileChooser_API> enter(chooser, true);
40 if (enter.failed()) 42 if (enter.failed())
41 return 0; 43 return 0;
42 return enter.object()->GetNextChosenFile(); 44 return enter.object()->GetNextChosenFile();
43 } 45 }
44 46
45 const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = { 47 const PPB_FileChooser_Dev g_ppb_file_chooser_thunk = {
46 &Create, 48 &Create,
47 &IsFileChooser, 49 &IsFileChooser,
48 &Show, 50 &Show,
49 &GetNextChosenFile 51 &GetNextChosenFile
50 }; 52 };
51 53
52 } // namespace 54 } // namespace
53 55
54 const PPB_FileChooser_Dev* GetPPB_FileChooser_Thunk() { 56 const PPB_FileChooser_Dev* GetPPB_FileChooser_Thunk() {
55 return &g_ppb_file_chooser_thunk; 57 return &g_ppb_file_chooser_thunk;
56 } 58 }
57 59
58 } // namespace thunk 60 } // namespace thunk
59 } // namespace ppapi 61 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_directory_reader_thunk.cc ('k') | ppapi/thunk/ppb_file_io_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698