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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // This property only mutates on the UI thread. | 75 // This property only mutates on the UI thread. |
76 bool is_fetching_; | 76 bool is_fetching_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(BrowsingDataFileSystemHelperImpl); | 78 DISALLOW_COPY_AND_ASSIGN(BrowsingDataFileSystemHelperImpl); |
79 }; | 79 }; |
80 | 80 |
81 BrowsingDataFileSystemHelperImpl::BrowsingDataFileSystemHelperImpl( | 81 BrowsingDataFileSystemHelperImpl::BrowsingDataFileSystemHelperImpl( |
82 fileapi::FileSystemContext* filesystem_context) | 82 fileapi::FileSystemContext* filesystem_context) |
83 : filesystem_context_(filesystem_context), | 83 : filesystem_context_(filesystem_context), |
84 is_fetching_(false) { | 84 is_fetching_(false) { |
85 DCHECK(filesystem_context_); | 85 DCHECK(filesystem_context_.get()); |
86 } | 86 } |
87 | 87 |
88 BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() { | 88 BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() { |
89 } | 89 } |
90 | 90 |
91 void BrowsingDataFileSystemHelperImpl::StartFetching( | 91 void BrowsingDataFileSystemHelperImpl::StartFetching( |
92 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { | 92 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { |
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
94 DCHECK(!is_fetching_); | 94 DCHECK(!is_fetching_); |
95 DCHECK_EQ(false, callback.is_null()); | 95 DCHECK_EQ(false, callback.is_null()); |
(...skipping 29 matching lines...) Expand all Loading... |
125 | 125 |
126 GURL current; | 126 GURL current; |
127 | 127 |
128 while (!(current = origin_enumerator->Next()).is_empty()) { | 128 while (!(current = origin_enumerator->Next()).is_empty()) { |
129 if (!BrowsingDataHelper::HasWebScheme(current)) | 129 if (!BrowsingDataHelper::HasWebScheme(current)) |
130 continue; // Non-websafe state is not considered browsing data. | 130 continue; // Non-websafe state is not considered browsing data. |
131 | 131 |
132 // 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 |
133 // we're running on the FILE thread. | 133 // we're running on the FILE thread. |
134 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread( | 134 int64 persistent_usage = quota_util->GetOriginUsageOnFileThread( |
135 filesystem_context_, current, | 135 filesystem_context_.get(), current, fileapi::kFileSystemTypePersistent); |
136 fileapi::kFileSystemTypePersistent); | |
137 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread( | 136 int64 temporary_usage = quota_util->GetOriginUsageOnFileThread( |
138 filesystem_context_, current, | 137 filesystem_context_.get(), current, fileapi::kFileSystemTypeTemporary); |
139 fileapi::kFileSystemTypeTemporary); | |
140 int64 syncable_usage = quota_util->GetOriginUsageOnFileThread( | 138 int64 syncable_usage = quota_util->GetOriginUsageOnFileThread( |
141 filesystem_context_, current, | 139 filesystem_context_.get(), current, fileapi::kFileSystemTypeSyncable); |
142 fileapi::kFileSystemTypeSyncable); | |
143 file_system_info_.push_back( | 140 file_system_info_.push_back( |
144 FileSystemInfo( | 141 FileSystemInfo( |
145 current, | 142 current, |
146 origin_enumerator->HasFileSystemType( | 143 origin_enumerator->HasFileSystemType( |
147 fileapi::kFileSystemTypePersistent), | 144 fileapi::kFileSystemTypePersistent), |
148 origin_enumerator->HasFileSystemType( | 145 origin_enumerator->HasFileSystemType( |
149 fileapi::kFileSystemTypeTemporary), | 146 fileapi::kFileSystemTypeTemporary), |
150 origin_enumerator->HasFileSystemType( | 147 origin_enumerator->HasFileSystemType( |
151 fileapi::kFileSystemTypeSyncable), | 148 fileapi::kFileSystemTypeSyncable), |
152 persistent_usage, | 149 persistent_usage, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); | 288 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); |
292 } | 289 } |
293 | 290 |
294 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { | 291 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { |
295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
296 DCHECK(is_fetching_); | 293 DCHECK(is_fetching_); |
297 completion_callback_.Run(file_system_info_); | 294 completion_callback_.Run(file_system_info_); |
298 completion_callback_.Reset(); | 295 completion_callback_.Reset(); |
299 is_fetching_ = false; | 296 is_fetching_ = false; |
300 } | 297 } |
OLD | NEW |