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

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: Fix self-assignment 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 13 matching lines...) Expand all
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 }
89 90
90 PluginInstance* instance = directory_ref_->instance(); 91 PluginInstance* instance = ResourceHelper::GetPluginInstance(directory_ref_);
91 if (!instance->delegate()->ReadDirectory( 92 if (!instance->delegate()->ReadDirectory(
92 directory_ref_->GetFileSystemURL(), 93 directory_ref_->GetFileSystemURL(),
93 new FileCallbacks(instance->module()->AsWeakPtr(), 94 new FileCallbacks(instance->module()->AsWeakPtr(),
94 pp_resource(), callback, NULL, NULL, this))) 95 pp_resource(), callback, NULL, NULL, this)))
95 return PP_ERROR_FAILED; 96 return PP_ERROR_FAILED;
96 97
97 return PP_OK_COMPLETIONPENDING; 98 return PP_OK_COMPLETIONPENDING;
98 } 99 }
99 100
100 void PPB_DirectoryReader_Impl::AddNewEntries( 101 void PPB_DirectoryReader_Impl::AddNewEntries(
(...skipping 17 matching lines...) Expand all
118 } 119 }
119 120
120 bool PPB_DirectoryReader_Impl::FillUpEntry() { 121 bool PPB_DirectoryReader_Impl::FillUpEntry() {
121 DCHECK(entry_); 122 DCHECK(entry_);
122 if (!entries_.empty()) { 123 if (!entries_.empty()) {
123 base::FileUtilProxy::Entry dir_entry = entries_.front(); 124 base::FileUtilProxy::Entry dir_entry = entries_.front();
124 entries_.pop(); 125 entries_.pop();
125 if (entry_->file_ref) 126 if (entry_->file_ref)
126 ResourceTracker::Get()->ReleaseResource(entry_->file_ref); 127 ResourceTracker::Get()->ReleaseResource(entry_->file_ref);
127 PPB_FileRef_Impl* file_ref = 128 PPB_FileRef_Impl* file_ref =
128 new PPB_FileRef_Impl(instance(), directory_ref_->file_system(), 129 new PPB_FileRef_Impl(pp_instance(), directory_ref_->file_system(),
129 FilePathStringToUTF8String(dir_entry.name)); 130 FilePathStringToUTF8String(dir_entry.name));
130 entry_->file_ref = file_ref->GetReference(); 131 entry_->file_ref = file_ref->GetReference();
131 entry_->file_type = 132 entry_->file_type =
132 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR); 133 (dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
133 return true; 134 return true;
134 } 135 }
135 136
136 if (!has_more_) { 137 if (!has_more_) {
137 entry_->file_ref = 0; 138 entry_->file_ref = 0;
138 return true; 139 return true;
139 } 140 }
140 141
141 return false; 142 return false;
142 } 143 }
143 144
144 } // namespace ppapi 145 } // namespace ppapi
145 } // namespace webkit 146 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698