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

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

Issue 26803004: PPAPI: Add PluginPrivateFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | « ppapi/proxy/file_system_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_system_resource.h" 5 #include "ppapi/proxy/file_system_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.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/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/tracked_callback.h" 11 #include "ppapi/shared_impl/tracked_callback.h"
12 12
13 using ppapi::thunk::PPB_FileSystem_API; 13 using ppapi::thunk::PPB_FileSystem_API;
14 14
15 namespace ppapi { 15 namespace ppapi {
16 namespace proxy { 16 namespace proxy {
17 17
18 FileSystemResource::FileSystemResource(Connection connection, 18 FileSystemResource::FileSystemResource(Connection connection,
19 PP_Instance instance, 19 PP_Instance instance,
20 PP_FileSystemType type) 20 PP_FileSystemType type)
21 : PluginResource(connection, instance), 21 : PluginResource(connection, instance),
22 type_(type), 22 type_(type),
23 called_open_(false), 23 called_open_(false),
24 callback_count_(0) { 24 callback_count_(0),
25 callback_result_(PP_OK) {
25 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); 26 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
26 SendCreate(RENDERER, PpapiHostMsg_FileSystem_Create(type_)); 27 SendCreate(RENDERER, PpapiHostMsg_FileSystem_Create(type_));
27 SendCreate(BROWSER, PpapiHostMsg_FileSystem_Create(type_)); 28 SendCreate(BROWSER, PpapiHostMsg_FileSystem_Create(type_));
28 } 29 }
29 30
30 FileSystemResource::FileSystemResource(Connection connection, 31 FileSystemResource::FileSystemResource(Connection connection,
31 PP_Instance instance, 32 PP_Instance instance,
32 int pending_renderer_id, 33 int pending_renderer_id,
33 int pending_browser_id, 34 int pending_browser_id,
34 PP_FileSystemType type) 35 PP_FileSystemType type)
35 : PluginResource(connection, instance), 36 : PluginResource(connection, instance),
36 type_(type), 37 type_(type),
37 called_open_(true) { 38 called_open_(true),
39 callback_count_(0),
40 callback_result_(PP_OK) {
38 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); 41 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
39 AttachToPendingHost(RENDERER, pending_renderer_id); 42 AttachToPendingHost(RENDERER, pending_renderer_id);
40 AttachToPendingHost(BROWSER, pending_browser_id); 43 AttachToPendingHost(BROWSER, pending_browser_id);
41 } 44 }
42 45
43 FileSystemResource::~FileSystemResource() { 46 FileSystemResource::~FileSystemResource() {
44 } 47 }
45 48
46 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { 49 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() {
47 return this; 50 return this;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, 95 base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete,
93 this, 96 this,
94 callback)); 97 callback));
95 return PP_OK_COMPLETIONPENDING; 98 return PP_OK_COMPLETIONPENDING;
96 } 99 }
97 100
98 void FileSystemResource::OpenComplete( 101 void FileSystemResource::OpenComplete(
99 scoped_refptr<TrackedCallback> callback, 102 scoped_refptr<TrackedCallback> callback,
100 const ResourceMessageReplyParams& params) { 103 const ResourceMessageReplyParams& params) {
101 ++callback_count_; 104 ++callback_count_;
105 // Prioritize worse result since only one status can be returned.
106 if (params.result() != PP_OK)
107 callback_result_ = params.result();
102 // Received callback from browser and renderer. 108 // Received callback from browser and renderer.
103 if (callback_count_ == 2) 109 if (callback_count_ == 2)
104 callback->Run(params.result()); 110 callback->Run(callback_result_);
105 } 111 }
106 112
107 void FileSystemResource::InitIsolatedFileSystemComplete( 113 void FileSystemResource::InitIsolatedFileSystemComplete(
108 const base::Callback<void(int32_t)>& callback, 114 const base::Callback<void(int32_t)>& callback,
109 const ResourceMessageReplyParams& params) { 115 const ResourceMessageReplyParams& params) {
110 ++callback_count_; 116 ++callback_count_;
117 // Prioritize worse result since only one status can be returned.
118 if (params.result() != PP_OK)
119 callback_result_ = params.result();
111 // Received callback from browser and renderer. 120 // Received callback from browser and renderer.
112 if (callback_count_ == 2) 121 if (callback_count_ == 2)
113 callback.Run(params.result()); 122 callback.Run(callback_result_);
114 } 123 }
115 124
116 } // namespace proxy 125 } // namespace proxy
117 } // namespace ppapi 126 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/file_system_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698