OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/plugin_private_storage_helper.h" | 5 #include "content/browser/plugin_private_storage_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::Bind(&PluginPrivateDataByOriginChecker::OnDirectoryRead, | 149 base::Bind(&PluginPrivateDataByOriginChecker::OnDirectoryRead, |
150 base::Unretained(this), root)); | 150 base::Unretained(this), root)); |
151 } | 151 } |
152 | 152 |
153 void PluginPrivateDataByOriginChecker::OnDirectoryRead( | 153 void PluginPrivateDataByOriginChecker::OnDirectoryRead( |
154 const std::string& root, | 154 const std::string& root, |
155 base::File::Error result, | 155 base::File::Error result, |
156 const storage::AsyncFileUtil::EntryList& file_list, | 156 const storage::AsyncFileUtil::EntryList& file_list, |
157 bool has_more) { | 157 bool has_more) { |
158 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 158 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
159 DVLOG(3) << __FUNCTION__ << " result: " << result | 159 DVLOG(3) << __func__ << " result: " << result |
160 << ", #files: " << file_list.size(); | 160 << ", #files: " << file_list.size(); |
161 | 161 |
162 // Quit if there is an error. | 162 // Quit if there is an error. |
163 if (result != base::File::FILE_OK) { | 163 if (result != base::File::FILE_OK) { |
164 DLOG(ERROR) << "Unable to read directory for " << origin_ << ":" | 164 DLOG(ERROR) << "Unable to read directory for " << origin_ << ":" |
165 << plugin_name_; | 165 << plugin_name_; |
166 DecrementTaskCount(); | 166 DecrementTaskCount(); |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 // No error, process the files returned. No need to do this if we have | 170 // No error, process the files returned. No need to do this if we have |
171 // already decided to delete all the data for this origin. | 171 // already decided to delete all the data for this origin. |
172 if (!delete_this_origin_data_) { | 172 if (!delete_this_origin_data_) { |
173 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( | 173 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( |
174 storage::kFileSystemTypePluginPrivate); | 174 storage::kFileSystemTypePluginPrivate); |
175 for (const auto& file : file_list) { | 175 for (const auto& file : file_list) { |
176 DVLOG(3) << __FUNCTION__ << " file: " << file.name; | 176 DVLOG(3) << __func__ << " file: " << file.name; |
177 DCHECK(!file.is_directory); // Nested directories not implemented. | 177 DCHECK(!file.is_directory); // Nested directories not implemented. |
178 | 178 |
179 std::unique_ptr<storage::FileSystemOperationContext> operation_context = | 179 std::unique_ptr<storage::FileSystemOperationContext> operation_context = |
180 base::WrapUnique( | 180 base::WrapUnique( |
181 new storage::FileSystemOperationContext(filesystem_context_)); | 181 new storage::FileSystemOperationContext(filesystem_context_)); |
182 storage::FileSystemURL file_url = filesystem_context_->CrackURL( | 182 storage::FileSystemURL file_url = filesystem_context_->CrackURL( |
183 GURL(root + StringTypeToString(file.name))); | 183 GURL(root + StringTypeToString(file.name))); |
184 IncrementTaskCount(); | 184 IncrementTaskCount(); |
185 file_util->GetFileInfo( | 185 file_util->GetFileInfo( |
186 std::move(operation_context), file_url, | 186 std::move(operation_context), file_url, |
(...skipping 11 matching lines...) Expand all Loading... |
198 DecrementTaskCount(); | 198 DecrementTaskCount(); |
199 } | 199 } |
200 | 200 |
201 void PluginPrivateDataByOriginChecker::OnFileInfo( | 201 void PluginPrivateDataByOriginChecker::OnFileInfo( |
202 const std::string& file_name, | 202 const std::string& file_name, |
203 base::File::Error result, | 203 base::File::Error result, |
204 const base::File::Info& file_info) { | 204 const base::File::Info& file_info) { |
205 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
206 | 206 |
207 if (result == base::File::FILE_OK) { | 207 if (result == base::File::FILE_OK) { |
208 DVLOG(3) << __FUNCTION__ << " name: " << file_name | 208 DVLOG(3) << __func__ << " name: " << file_name |
209 << ", size: " << file_info.size | 209 << ", size: " << file_info.size |
210 << ", modified: " << file_info.last_modified; | 210 << ", modified: " << file_info.last_modified; |
211 if (file_info.last_modified >= begin_ && file_info.last_modified <= end_) | 211 if (file_info.last_modified >= begin_ && file_info.last_modified <= end_) |
212 delete_this_origin_data_ = true; | 212 delete_this_origin_data_ = true; |
213 } | 213 } |
214 | 214 |
215 DecrementTaskCount(); | 215 DecrementTaskCount(); |
216 } | 216 } |
217 | 217 |
218 void PluginPrivateDataByOriginChecker::IncrementTaskCount() { | 218 void PluginPrivateDataByOriginChecker::IncrementTaskCount() { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 origins.insert(storage_origin); | 406 origins.insert(storage_origin); |
407 } | 407 } |
408 | 408 |
409 PluginPrivateDataDeletionHelper* helper = new PluginPrivateDataDeletionHelper( | 409 PluginPrivateDataDeletionHelper* helper = new PluginPrivateDataDeletionHelper( |
410 std::move(filesystem_context), begin, end, callback); | 410 std::move(filesystem_context), begin, end, callback); |
411 helper->CheckOriginsOnFileTaskRunner(origins); | 411 helper->CheckOriginsOnFileTaskRunner(origins); |
412 // |helper| will delete itself when all origins have been checked. | 412 // |helper| will delete itself when all origins have been checked. |
413 } | 413 } |
414 | 414 |
415 } // namespace content | 415 } // namespace content |
OLD | NEW |