| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "webkit/fileapi/file_system_context.h" | 17 #include "webkit/fileapi/file_system_context.h" |
| 18 #include "webkit/fileapi/file_system_quota_util.h" | 18 #include "webkit/fileapi/file_system_quota_util.h" |
| 19 #include "webkit/fileapi/file_system_types.h" | 19 #include "webkit/fileapi/file_system_types.h" |
| 20 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 20 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 21 | 21 |
| 22 using content::BrowserContext; | 22 using content::BrowserContext; |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 | 24 |
| 25 namespace fileapi { |
| 26 class FileSystemContext; |
| 27 } |
| 28 |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 // An implementation of the BrowsingDataFileSystemHelper interface that pulls | 31 // An implementation of the BrowsingDataFileSystemHelper interface that pulls |
| 28 // data from a given |profile| and returns a list of FileSystemInfo items to a | 32 // data from a given |context| and returns a list of FileSystemInfo items to a |
| 29 // client. | 33 // client. |
| 30 class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { | 34 class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { |
| 31 public: | 35 public: |
| 32 // BrowsingDataFileSystemHelper implementation | 36 // BrowsingDataFileSystemHelper implementation |
| 33 explicit BrowsingDataFileSystemHelperImpl(Profile* profile); | 37 explicit BrowsingDataFileSystemHelperImpl( |
| 38 fileapi::FileSystemContext* context); |
| 34 virtual void StartFetching(const base::Callback< | 39 virtual void StartFetching(const base::Callback< |
| 35 void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; | 40 void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; |
| 36 virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE; | 41 virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE; |
| 37 | 42 |
| 38 private: | 43 private: |
| 39 virtual ~BrowsingDataFileSystemHelperImpl(); | 44 virtual ~BrowsingDataFileSystemHelperImpl(); |
| 40 | 45 |
| 41 // Enumerates all filesystem files, storing the resulting list into | 46 // Enumerates all filesystem files, storing the resulting list into |
| 42 // file_system_file_ for later use. This must be called on the FILE thread. | 47 // file_system_file_ for later use. This must be called on the FILE thread. |
| 43 void FetchFileSystemInfoInFileThread(); | 48 void FetchFileSystemInfoInFileThread(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 // Indicates whether or not we're currently fetching information: set to true | 75 // Indicates whether or not we're currently fetching information: set to true |
| 71 // when StartFetching is called on the UI thread, and reset to false when | 76 // when StartFetching is called on the UI thread, and reset to false when |
| 72 // NotifyOnUIThread triggers the success callback. | 77 // NotifyOnUIThread triggers the success callback. |
| 73 // This property only mutates on the UI thread. | 78 // This property only mutates on the UI thread. |
| 74 bool is_fetching_; | 79 bool is_fetching_; |
| 75 | 80 |
| 76 DISALLOW_COPY_AND_ASSIGN(BrowsingDataFileSystemHelperImpl); | 81 DISALLOW_COPY_AND_ASSIGN(BrowsingDataFileSystemHelperImpl); |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 BrowsingDataFileSystemHelperImpl::BrowsingDataFileSystemHelperImpl( | 84 BrowsingDataFileSystemHelperImpl::BrowsingDataFileSystemHelperImpl( |
| 80 Profile* profile) | 85 fileapi::FileSystemContext* context) |
| 81 : filesystem_context_(BrowserContext::GetFileSystemContext(profile)), | 86 : filesystem_context_(context), |
| 82 is_fetching_(false) { | 87 is_fetching_(false) { |
| 83 DCHECK(filesystem_context_); | 88 DCHECK(filesystem_context_); |
| 84 } | 89 } |
| 85 | 90 |
| 86 BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() { | 91 BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() { |
| 87 } | 92 } |
| 88 | 93 |
| 89 void BrowsingDataFileSystemHelperImpl::StartFetching( | 94 void BrowsingDataFileSystemHelperImpl::StartFetching( |
| 90 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { | 95 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { |
| 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 has_persistent(has_persistent), | 182 has_persistent(has_persistent), |
| 178 has_temporary(has_temporary), | 183 has_temporary(has_temporary), |
| 179 usage_persistent(usage_persistent), | 184 usage_persistent(usage_persistent), |
| 180 usage_temporary(usage_temporary) { | 185 usage_temporary(usage_temporary) { |
| 181 } | 186 } |
| 182 | 187 |
| 183 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} | 188 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} |
| 184 | 189 |
| 185 // static | 190 // static |
| 186 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create( | 191 BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create( |
| 187 Profile* profile) { | 192 fileapi::FileSystemContext* file_system_context) { |
| 188 return new BrowsingDataFileSystemHelperImpl(profile); | 193 return new BrowsingDataFileSystemHelperImpl(file_system_context); |
| 189 } | 194 } |
| 190 | 195 |
| 191 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper( | 196 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper( |
| 192 Profile* profile) | 197 Profile* profile) |
| 193 : is_fetching_(false) { | 198 : is_fetching_(false) { |
| 194 } | 199 } |
| 195 | 200 |
| 196 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper() | 201 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper() |
| 197 : is_fetching_(false) { | 202 : is_fetching_(false) { |
| 198 } | 203 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); | 279 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); |
| 275 } | 280 } |
| 276 | 281 |
| 277 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { | 282 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 279 DCHECK(is_fetching_); | 284 DCHECK(is_fetching_); |
| 280 completion_callback_.Run(file_system_info_); | 285 completion_callback_.Run(file_system_info_); |
| 281 completion_callback_.Reset(); | 286 completion_callback_.Reset(); |
| 282 is_fetching_ = false; | 287 is_fetching_ = false; |
| 283 } | 288 } |
| OLD | NEW |