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

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

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments 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"
(...skipping 28 matching lines...) Expand all
39 PPB_FileSystem_Impl::~PPB_FileSystem_Impl() { 39 PPB_FileSystem_Impl::~PPB_FileSystem_Impl() {
40 } 40 }
41 41
42 // static 42 // static
43 PP_Resource PPB_FileSystem_Impl::Create(PluginInstance* instance, 43 PP_Resource PPB_FileSystem_Impl::Create(PluginInstance* instance,
44 PP_FileSystemType type) { 44 PP_FileSystemType type) {
45 if (type != PP_FILESYSTEMTYPE_EXTERNAL && 45 if (type != PP_FILESYSTEMTYPE_EXTERNAL &&
46 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 46 type != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
47 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 47 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
48 return 0; 48 return 0;
49 49 return (new PPB_FileSystem_Impl(instance, type))->GetReference();
50 PPB_FileSystem_Impl* file_system = new PPB_FileSystem_Impl(instance, type);
51 return file_system->GetReference();
52 } 50 }
53 51
54 PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() { 52 PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() {
55 return this; 53 return this;
56 } 54 }
57 55
58 int32_t PPB_FileSystem_Impl::Open(int64_t expected_size, 56 int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
59 PP_CompletionCallback callback) { 57 PP_CompletionCallback callback) {
60 // Should not allow multiple opens. 58 // Should not allow multiple opens.
61 if (called_open_) 59 if (called_open_)
62 return PP_ERROR_INPROGRESS; 60 return PP_ERROR_INPROGRESS;
63 called_open_ = true; 61 called_open_ = true;
64 62
65 if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 63 if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
66 type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) 64 type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
67 return PP_ERROR_FAILED; 65 return PP_ERROR_FAILED;
68 66
69 fileapi::FileSystemType file_system_type = 67 fileapi::FileSystemType file_system_type =
70 (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ? 68 (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
71 fileapi::kFileSystemTypeTemporary : 69 fileapi::kFileSystemTypeTemporary :
72 fileapi::kFileSystemTypePersistent); 70 fileapi::kFileSystemTypePersistent);
73 if (!instance()->delegate()->OpenFileSystem( 71 if (!instance()->delegate()->OpenFileSystem(
74 instance()->container()->element().document().url(), 72 instance()->container()->element().document().url(),
75 file_system_type, expected_size, 73 file_system_type, expected_size,
76 new FileCallbacks(instance()->module()->AsWeakPtr(), 74 new FileCallbacks(instance()->module()->AsWeakPtr(),
77 GetReferenceNoAddRef(), 75 pp_resource(), callback, NULL,
78 callback, NULL,
79 scoped_refptr<PPB_FileSystem_Impl>(this), NULL))) 76 scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
80 return PP_ERROR_FAILED; 77 return PP_ERROR_FAILED;
81 return PP_OK_COMPLETIONPENDING; 78 return PP_OK_COMPLETIONPENDING;
82 } 79 }
83 80
84 PP_FileSystemType PPB_FileSystem_Impl::GetType() { 81 PP_FileSystemType PPB_FileSystem_Impl::GetType() {
85 return type_; 82 return type_;
86 } 83 }
87 84
88 } // namespace ppapi 85 } // namespace ppapi
89 } // namespace webkit 86 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698