| 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_file_system_helper.h" | 5 #include "chrome/browser/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/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "webkit/fileapi/file_system_context.h" | 16 #include "webkit/fileapi/file_system_context.h" |
| 17 #include "webkit/fileapi/file_system_quota_util.h" | 17 #include "webkit/fileapi/file_system_quota_util.h" |
| 18 #include "webkit/fileapi/file_system_types.h" | 18 #include "webkit/fileapi/file_system_types.h" |
| 19 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 19 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 20 | 20 |
| 21 using content::BrowserContext; |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // An implementation of the BrowsingDataFileSystemHelper interface that pulls | 26 // An implementation of the BrowsingDataFileSystemHelper interface that pulls |
| 26 // data from a given |profile| and returns a list of FileSystemInfo items to a | 27 // data from a given |profile| and returns a list of FileSystemInfo items to a |
| 27 // client. | 28 // client. |
| 28 class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { | 29 class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { |
| 29 public: | 30 public: |
| 30 // BrowsingDataFileSystemHelper implementation | 31 // BrowsingDataFileSystemHelper implementation |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
| 107 BrowserThread::FILE, FROM_HERE, | 108 BrowserThread::FILE, FROM_HERE, |
| 108 base::Bind( | 109 base::Bind( |
| 109 &BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread, | 110 &BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread, |
| 110 this, origin)); | 111 this, origin)); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() { | 114 void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() { |
| 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 115 scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator> | 116 scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator> |
| 116 origin_enumerator(profile_->GetFileSystemContext()-> | 117 origin_enumerator(BrowserContext::GetFileSystemContext(profile_)-> |
| 117 sandbox_provider()->CreateOriginEnumerator()); | 118 sandbox_provider()->CreateOriginEnumerator()); |
| 118 | 119 |
| 119 // We don't own this pointer; it's a magic singleton generated by the | 120 // We don't own this pointer; it's a magic singleton generated by the |
| 120 // profile's FileSystemContext. Deleting it would be a bad idea. | 121 // profile's FileSystemContext. Deleting it would be a bad idea. |
| 121 fileapi::FileSystemQuotaUtil* quota_util = profile_-> | 122 fileapi::FileSystemQuotaUtil* quota_util = |
| 122 GetFileSystemContext()->GetQuotaUtil(fileapi::kFileSystemTypeTemporary); | 123 BrowserContext::GetFileSystemContext(profile_)->GetQuotaUtil( |
| 124 fileapi::kFileSystemTypeTemporary); |
| 123 | 125 |
| 124 GURL current; | 126 GURL current; |
| 125 while (!(current = origin_enumerator->Next()).is_empty()) { | 127 while (!(current = origin_enumerator->Next()).is_empty()) { |
| 126 if (current.SchemeIs(chrome::kExtensionScheme)) { | 128 if (current.SchemeIs(chrome::kExtensionScheme)) { |
| 127 // Extension state is not considered browsing data. | 129 // Extension state is not considered browsing data. |
| 128 continue; | 130 continue; |
| 129 } | 131 } |
| 130 // We can call these synchronous methods as we've already verified that | 132 // We can call these synchronous methods as we've already verified that |
| 131 // we're running on the FILE thread. | 133 // we're running on the FILE thread. |
| 132 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current, | 134 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 157 if (!completion_callback_.is_null()) { | 159 if (!completion_callback_.is_null()) { |
| 158 completion_callback_.Run(file_system_info_); | 160 completion_callback_.Run(file_system_info_); |
| 159 completion_callback_.Reset(); | 161 completion_callback_.Reset(); |
| 160 } | 162 } |
| 161 is_fetching_ = false; | 163 is_fetching_ = false; |
| 162 } | 164 } |
| 163 | 165 |
| 164 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread( | 166 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread( |
| 165 const GURL& origin) { | 167 const GURL& origin) { |
| 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 167 profile_->GetFileSystemContext()->DeleteDataForOriginOnFileThread(origin); | 169 BrowserContext::GetFileSystemContext(profile_)-> |
| 170 DeleteDataForOriginOnFileThread(origin); |
| 168 } | 171 } |
| 169 | 172 |
| 170 } // namespace | 173 } // namespace |
| 171 | 174 |
| 172 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo( | 175 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo( |
| 173 const GURL& origin, | 176 const GURL& origin, |
| 174 bool has_persistent, | 177 bool has_persistent, |
| 175 bool has_temporary, | 178 bool has_temporary, |
| 176 int64 usage_persistent, | 179 int64 usage_persistent, |
| 177 int64 usage_temporary) | 180 int64 usage_temporary) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 completion_callback_.Run(file_system_info_); | 278 completion_callback_.Run(file_system_info_); |
| 276 completion_callback_.Reset(); | 279 completion_callback_.Reset(); |
| 277 } | 280 } |
| 278 is_fetching_ = false; | 281 is_fetching_ = false; |
| 279 } | 282 } |
| 280 | 283 |
| 281 void CannedBrowsingDataFileSystemHelper::CancelNotification() { | 284 void CannedBrowsingDataFileSystemHelper::CancelNotification() { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 283 completion_callback_.Reset(); | 286 completion_callback_.Reset(); |
| 284 } | 287 } |
| OLD | NEW |