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

Side by Side Diff: webkit/plugins/ppapi/ppb_file_system_impl.cc

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nulls auditeed Created 9 years, 4 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) 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 "webkit/plugins/ppapi/ppb_file_system_impl.h" 5 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "ppapi/c/pp_completion_callback.h" 8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/ppb_file_system.h" 9 #include "ppapi/c/ppb_file_system.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
14 #include "webkit/fileapi/file_system_types.h" 14 #include "webkit/fileapi/file_system_types.h"
15 #include "webkit/plugins/ppapi/common.h" 15 #include "webkit/plugins/ppapi/common.h"
16 #include "webkit/plugins/ppapi/file_callbacks.h" 16 #include "webkit/plugins/ppapi/file_callbacks.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h" 17 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" 20 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
21 #include "webkit/plugins/ppapi/resource.h" 21 #include "webkit/plugins/ppapi/resource_helper.h"
22 #include "webkit/plugins/ppapi/resource_tracker.h"
23 22
24 using ppapi::thunk::PPB_FileSystem_API; 23 using ppapi::thunk::PPB_FileSystem_API;
25 24
26 namespace webkit { 25 namespace webkit {
27 namespace ppapi { 26 namespace ppapi {
28 27
29 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, 28 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PP_Instance instance,
30 PP_FileSystemType type) 29 PP_FileSystemType type)
31 : Resource(instance), 30 : Resource(instance),
32 instance_(instance),
33 type_(type), 31 type_(type),
34 opened_(false), 32 opened_(false),
35 called_open_(false) { 33 called_open_(false) {
36 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); 34 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
37 } 35 }
38 36
39 PPB_FileSystem_Impl::~PPB_FileSystem_Impl() { 37 PPB_FileSystem_Impl::~PPB_FileSystem_Impl() {
40 } 38 }
41 39
42 // static 40 // static
43 PP_Resource PPB_FileSystem_Impl::Create(PluginInstance* instance, 41 PP_Resource PPB_FileSystem_Impl::Create(PP_Instance instance,
44 PP_FileSystemType type) { 42 PP_FileSystemType type) {
45 if (type != PP_FILESYSTEMTYPE_EXTERNAL && 43 if (type != PP_FILESYSTEMTYPE_EXTERNAL &&
46 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 44 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
47 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 45 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
48 return 0; 46 return 0;
49 return (new PPB_FileSystem_Impl(instance, type))->GetReference(); 47 return (new PPB_FileSystem_Impl(instance, type))->GetReference();
50 } 48 }
51 49
52 PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() { 50 PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() {
53 return this; 51 return this;
54 } 52 }
55 53
56 int32_t PPB_FileSystem_Impl::Open(int64_t expected_size, 54 int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
57 PP_CompletionCallback callback) { 55 PP_CompletionCallback callback) {
58 // Should not allow multiple opens. 56 // Should not allow multiple opens.
59 if (called_open_) 57 if (called_open_)
60 return PP_ERROR_INPROGRESS; 58 return PP_ERROR_INPROGRESS;
61 called_open_ = true; 59 called_open_ = true;
62 60
63 if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 61 if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
64 type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 62 type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
65 return PP_ERROR_FAILED; 63 return PP_ERROR_FAILED;
66 64
65 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
66 if (!plugin_instance)
67 return PP_ERROR_FAILED;
68
67 fileapi::FileSystemType file_system_type = 69 fileapi::FileSystemType file_system_type =
68 (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ? 70 (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
69 fileapi::kFileSystemTypeTemporary : 71 fileapi::kFileSystemTypeTemporary :
70 fileapi::kFileSystemTypePersistent); 72 fileapi::kFileSystemTypePersistent);
71 if (!instance()->delegate()->OpenFileSystem( 73 if (!plugin_instance->delegate()->OpenFileSystem(
72 instance()->container()->element().document().url(), 74 plugin_instance->container()->element().document().url(),
73 file_system_type, expected_size, 75 file_system_type, expected_size,
74 new FileCallbacks(instance()->module()->AsWeakPtr(), 76 new FileCallbacks(plugin_instance->module()->AsWeakPtr(),
75 pp_resource(), callback, NULL, 77 pp_resource(), callback, NULL,
76 scoped_refptr<PPB_FileSystem_Impl>(this), NULL))) 78 scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
77 return PP_ERROR_FAILED; 79 return PP_ERROR_FAILED;
78 return PP_OK_COMPLETIONPENDING; 80 return PP_OK_COMPLETIONPENDING;
79 } 81 }
80 82
81 PP_FileSystemType PPB_FileSystem_Impl::GetType() { 83 PP_FileSystemType PPB_FileSystem_Impl::GetType() {
82 return type_; 84 return type_;
83 } 85 }
84 86
85 } // namespace ppapi 87 } // namespace ppapi
86 } // namespace webkit 88 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_system_impl.h ('k') | webkit/plugins/ppapi/ppb_flash_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698