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

Side by Side Diff: webkit/plugins/ppapi/ppb_directory_reader_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_directory_reader_impl.h" 5 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/c/dev/ppb_directory_reader_dev.h" 11 #include "ppapi/c/dev/ppb_directory_reader_dev.h"
12 #include "ppapi/thunk/enter.h" 12 #include "ppapi/thunk/enter.h"
13 #include "ppapi/thunk/ppb_file_ref_api.h" 13 #include "ppapi/thunk/ppb_file_ref_api.h"
14 #include "webkit/plugins/ppapi/common.h" 14 #include "webkit/plugins/ppapi/common.h"
15 #include "webkit/plugins/ppapi/file_callbacks.h" 15 #include "webkit/plugins/ppapi/file_callbacks.h"
16 #include "webkit/plugins/ppapi/plugin_delegate.h" 16 #include "webkit/plugins/ppapi/plugin_delegate.h"
17 #include "webkit/plugins/ppapi/plugin_module.h" 17 #include "webkit/plugins/ppapi/plugin_module.h"
18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
19 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" 19 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
20 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" 20 #include "webkit/plugins/ppapi/ppb_file_system_impl.h"
21 #include "webkit/plugins/ppapi/resource_helper.h"
21 #include "webkit/plugins/ppapi/resource_tracker.h" 22 #include "webkit/plugins/ppapi/resource_tracker.h"
22 23
23 using ::ppapi::thunk::EnterResourceNoLock; 24 using ::ppapi::thunk::EnterResourceNoLock;
24 using ::ppapi::thunk::PPB_DirectoryReader_API; 25 using ::ppapi::thunk::PPB_DirectoryReader_API;
25 using ::ppapi::thunk::PPB_FileRef_API; 26 using ::ppapi::thunk::PPB_FileRef_API;
26 27
27 namespace webkit { 28 namespace webkit {
28 namespace ppapi { 29 namespace ppapi {
29 30
30 namespace { 31 namespace {
(...skipping 15 matching lines...) Expand all
46 return str; 47 return str;
47 #else 48 #else
48 #error "Unsupported platform." 49 #error "Unsupported platform."
49 #endif 50 #endif
50 } 51 }
51 52
52 } // namespace 53 } // namespace
53 54
54 PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl( 55 PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
55 PPB_FileRef_Impl* directory_ref) 56 PPB_FileRef_Impl* directory_ref)
56 : Resource(directory_ref->instance()), 57 : Resource(directory_ref->pp_instance()),
57 directory_ref_(directory_ref), 58 directory_ref_(directory_ref),
58 has_more_(true), 59 has_more_(true),
59 entry_(NULL) { 60 entry_(NULL) {
60 } 61 }
61 62
62 PPB_DirectoryReader_Impl::~PPB_DirectoryReader_Impl() { 63 PPB_DirectoryReader_Impl::~PPB_DirectoryReader_Impl() {
63 } 64 }
64 65
65 // static 66 // static
66 PP_Resource PPB_DirectoryReader_Impl::Create(PP_Resource directory_ref) { 67 PP_Resource PPB_DirectoryReader_Impl::Create(PP_Resource directory_ref) {
(...skipping 12 matching lines...) Expand all
79 PP_DirectoryEntry_Dev* entry, 80 PP_DirectoryEntry_Dev* entry,
80 PP_CompletionCallback callback) { 81 PP_CompletionCallback callback) {
81 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) 82 if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
82 return PP_ERROR_FAILED; 83 return PP_ERROR_FAILED;
83 84
84 entry_ = entry; 85 entry_ = entry;
85 if (FillUpEntry()) { 86 if (FillUpEntry()) {
86 entry_ = NULL; 87 entry_ = NULL;
87 return PP_OK; 88 return PP_OK;
88 } 89 }
90 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
91 if (!plugin_instance)
92 return PP_ERROR_FAILED;
89 93
90 PluginInstance* instance = directory_ref_->instance(); 94 if (!plugin_instance->delegate()->ReadDirectory(
91 if (!instance->delegate()->ReadDirectory(
92 directory_ref_->GetFileSystemURL(), 95 directory_ref_->GetFileSystemURL(),
93 new FileCallbacks(instance->module()->AsWeakPtr(), 96 new FileCallbacks(plugin_instance->module()->AsWeakPtr(),
94 pp_resource(), callback, NULL, NULL, this))) 97 pp_resource(), callback, NULL, NULL, this)))
95 return PP_ERROR_FAILED; 98 return PP_ERROR_FAILED;
96 99
97 return PP_OK_COMPLETIONPENDING; 100 return PP_OK_COMPLETIONPENDING;
98 } 101 }
99 102
100 void PPB_DirectoryReader_Impl::AddNewEntries( 103 void PPB_DirectoryReader_Impl::AddNewEntries(
101 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { 104 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
102 DCHECK(!entries.empty() || !has_more); 105 DCHECK(!entries.empty() || !has_more);
103 has_more_ = has_more; 106 has_more_ = has_more;
(...skipping 14 matching lines...) Expand all
118 } 121 }
119 122
120 bool PPB_DirectoryReader_Impl::FillUpEntry() { 123 bool PPB_DirectoryReader_Impl::FillUpEntry() {
121 DCHECK(entry_); 124 DCHECK(entry_);
122 if (!entries_.empty()) { 125 if (!entries_.empty()) {
123 base::FileUtilProxy::Entry dir_entry = entries_.front(); 126 base::FileUtilProxy::Entry dir_entry = entries_.front();
124 entries_.pop(); 127 entries_.pop();
125 if (entry_->file_ref) 128 if (entry_->file_ref)
126 ResourceTracker::Get()->ReleaseResource(entry_->file_ref); 129 ResourceTracker::Get()->ReleaseResource(entry_->file_ref);
127 PPB_FileRef_Impl* file_ref = 130 PPB_FileRef_Impl* file_ref =
128 new PPB_FileRef_Impl(instance(), directory_ref_->file_system(), 131 new PPB_FileRef_Impl(pp_instance(), directory_ref_->file_system(),
129 FilePathStringToUTF8String(dir_entry.name)); 132 FilePathStringToUTF8String(dir_entry.name));
130 entry_->file_ref = file_ref->GetReference(); 133 entry_->file_ref = file_ref->GetReference();
131 entry_->file_type = 134 entry_->file_type =
132 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); 135 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
133 return true; 136 return true;
134 } 137 }
135 138
136 if (!has_more_) { 139 if (!has_more_) {
137 entry_->file_ref = 0; 140 entry_->file_ref = 0;
138 return true; 141 return true;
139 } 142 }
140 143
141 return false; 144 return false;
142 } 145 }
143 146
144 } // namespace ppapi 147 } // namespace ppapi
145 } // namespace webkit 148 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_directory_reader_impl.h ('k') | webkit/plugins/ppapi/ppb_file_chooser_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698