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

Side by Side Diff: webkit/glue/plugins/pepper_file_system.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | « webkit/glue/plugins/pepper_file_system.h ('k') | webkit/glue/plugins/pepper_font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/glue/plugins/pepper_file_system.h"
6
7 #include "base/ref_counted.h"
8 #include "ppapi/c/dev/ppb_file_system_dev.h"
9 #include "ppapi/c/pp_completion_callback.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
14 #include "webkit/fileapi/file_system_types.h"
15 #include "webkit/glue/plugins/pepper_directory_reader.h"
16 #include "webkit/glue/plugins/pepper_file_callbacks.h"
17 #include "webkit/glue/plugins/pepper_plugin_delegate.h"
18 #include "webkit/glue/plugins/pepper_plugin_instance.h"
19 #include "webkit/glue/plugins/pepper_plugin_module.h"
20 #include "webkit/glue/plugins/pepper_resource.h"
21 #include "webkit/glue/plugins/pepper_resource_tracker.h"
22
23 namespace pepper {
24
25 namespace {
26
27 PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) {
28 PluginInstance* plugin_instance =
29 ResourceTracker::Get()->GetInstance(instance);
30 if (!plugin_instance)
31 return 0;
32
33 FileSystem* file_system = new FileSystem(plugin_instance, type);
34 return file_system->GetReference();
35 }
36
37 int32_t Open(PP_Resource file_system_id,
38 int64 expected_size,
39 PP_CompletionCallback callback) {
40 scoped_refptr<FileSystem> file_system(
41 Resource::GetAs<FileSystem>(file_system_id));
42 if (!file_system)
43 return PP_ERROR_BADRESOURCE;
44
45 if (file_system->opened())
46 return PP_OK;
47
48 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
49 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY))
50 return PP_ERROR_FAILED;
51
52 PluginInstance* instance = file_system->instance();
53 fileapi::FileSystemType file_system_type =
54 (file_system->type() == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
55 fileapi::kFileSystemTypeTemporary :
56 fileapi::kFileSystemTypePersistent);
57 if (!instance->delegate()->OpenFileSystem(
58 instance->container()->element().document().frame()->url(),
59 file_system_type, expected_size,
60 new FileCallbacks(instance->module()->AsWeakPtr(),
61 callback, NULL, file_system, NULL)))
62 return PP_ERROR_FAILED;
63
64 return PP_ERROR_WOULDBLOCK;
65 }
66
67 const PPB_FileSystem_Dev ppb_filesystem = {
68 &Create,
69 &Open
70 };
71
72 } // namespace
73
74 FileSystem::FileSystem(PluginInstance* instance, PP_FileSystemType_Dev type)
75 : Resource(instance->module()),
76 instance_(instance),
77 type_(type),
78 opened_(false) {
79 }
80
81 FileSystem* FileSystem::AsFileSystem() {
82 return this;
83 }
84
85 const PPB_FileSystem_Dev* FileSystem::GetInterface() {
86 return &ppb_filesystem;
87 }
88
89 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_file_system.h ('k') | webkit/glue/plugins/pepper_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698