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

Unified Diff: chrome/browser/browsing_data_file_system_helper.cc

Issue 7104026: Stylistic fixes for BrowsingDataFileSystemHelper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dropping profile from CannedBrowsingDataThingie. Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browsing_data_file_system_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browsing_data_file_system_helper.cc
diff --git a/chrome/browser/browsing_data_file_system_helper.cc b/chrome/browser/browsing_data_file_system_helper.cc
index 065645b5a8612a14533ff838070c01e7fb51adca..a93f1428b8685bb6b735516d48fe3636b61f828f 100644
--- a/chrome/browser/browsing_data_file_system_helper.cc
+++ b/chrome/browser/browsing_data_file_system_helper.cc
@@ -11,24 +11,20 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "content/browser/browser_thread.h"
-#include "content/browser/in_process_webkit/webkit_context.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "webkit/fileapi/file_system_quota_util.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
-#include "webkit/glue/webkit_glue.h"
-
-using WebKit::WebSecurityOrigin;
namespace {
+// An implementation of the BrowsingDataFileSystemHelper interface that pulls
+// data from a given |profile| and returns a list of FileSystemInfo items to a
+// client.
class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper {
public:
+ // BrowsingDataFileSystemHelper implementation
explicit BrowsingDataFileSystemHelperImpl(Profile* profile);
-
virtual void StartFetching(
Callback1<const std::vector<FileSystemInfo>& >::Type* callback);
virtual void CancelNotification();
@@ -37,26 +33,36 @@ class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper {
private:
virtual ~BrowsingDataFileSystemHelperImpl();
- // Enumerates all filesystem files in the FILE thread.
+ // Enumerates all filesystem files, storing the resulting list into
+ // file_system_file_ for later use. This must be called on the FILE thread.
void FetchFileSystemInfoInFileThread();
- // Notifies the completion callback in the UI thread.
- void NotifyInUIThread();
- // Delete data for an origin on the FILE thread.
+
+ // Triggers the success callback as the end of a StartFetching workflow. This
+ // must be called on the UI thread.
+ void NotifyOnUIThread();
+
+ // Deletes all file systems associated with |origin|. This must be called on
+ // the FILE thread.
void DeleteFileSystemOriginInFileThread(const GURL& origin);
+ // We don't own the Profile object. Clients are responsible for destroying the
+ // object when it's no longer used.
Profile* profile_;
- // This only mutates in the FILE thread.
+ // Holds the current list of file systems returned to the client after
+ // StartFetching is called. This only mutates in the FILE thread.
std::vector<FileSystemInfo> file_system_info_;
- // This only mutates on the UI thread.
+ // Holds the callback passed in at the beginning of the StartFetching workflow
+ // so that it can be triggered via NotifyOnUIThread. This only mutates on the
+ // UI thread.
scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type >
completion_callback_;
- // Indicates whether or not we're currently fetching information:
- // it's true when StartFetching() is called in the UI thread, and it's reset
- // after we notified the callback in the UI thread.
- // This only mutates on the UI thread.
+ // Indicates whether or not we're currently fetching information: set to true
+ // when StartFetching is called on the UI thread, and reset to false when
+ // NotifyOnUIThread triggers the success callback.
+ // This property only mutates on the UI thread.
bool is_fetching_;
DISALLOW_COPY_AND_ASSIGN(BrowsingDataFileSystemHelperImpl);
@@ -109,7 +115,9 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator>
origin_enumerator(profile_->GetFileSystemContext()->path_manager()->
sandbox_provider()->CreateOriginEnumerator());
- // We don't own this pointer; deleting it would be a bad idea.
+
+ // We don't own this pointer; it's a magic singleton generated by the
+ // profile's FileSystemContext. Deleting it would be a bad idea.
fileapi::FileSystemQuotaUtil* quota_util = profile_->
GetFileSystemContext()->GetQuotaUtil(fileapi::kFileSystemTypeTemporary);
@@ -119,6 +127,8 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
// Extension state is not considered browsing data.
continue;
}
+ // We can call these synchronous methods as we've already verified that
+ // we're running on the FILE thread.
int64 persistent_usage = quota_util->GetOriginUsageOnFileThread(current,
fileapi::kFileSystemTypePersistent);
int64 temporary_usage = quota_util->GetOriginUsageOnFileThread(current,
@@ -137,14 +147,14 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &BrowsingDataFileSystemHelperImpl::NotifyInUIThread));
+ this, &BrowsingDataFileSystemHelperImpl::NotifyOnUIThread));
}
-void BrowsingDataFileSystemHelperImpl::NotifyInUIThread() {
+void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(is_fetching_);
- // Note: completion_callback_ mutates only in the UI thread, so it's safe to
- // test it here.
+ // completion_callback_ mutates only in the UI thread, so we're safe to test
+ // it here.
if (completion_callback_ != NULL) {
completion_callback_->Run(file_system_info_);
completion_callback_.reset();
@@ -182,27 +192,30 @@ BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create(
}
CannedBrowsingDataFileSystemHelper::
-PendingFileSystemInfo::PendingFileSystemInfo() {
+ PendingFileSystemInfo::PendingFileSystemInfo() {
}
CannedBrowsingDataFileSystemHelper::
-PendingFileSystemInfo::PendingFileSystemInfo(const GURL& origin,
- const fileapi::FileSystemType type,
- int64 size)
+ PendingFileSystemInfo::PendingFileSystemInfo(
+ const GURL& origin,
+ const fileapi::FileSystemType type,
+ int64 size)
: origin(origin),
type(type),
size(size) {
}
CannedBrowsingDataFileSystemHelper::
-PendingFileSystemInfo::~PendingFileSystemInfo() {
+ PendingFileSystemInfo::~PendingFileSystemInfo() {
}
CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper(
- Profile* profile)
- : profile_(profile),
- is_fetching_(false) {
- DCHECK(profile);
+ Profile* /* profile */)
+ : is_fetching_(false) {
+}
+
+CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper()
+ : is_fetching_(false) {
}
CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {}
@@ -211,8 +224,7 @@ CannedBrowsingDataFileSystemHelper*
CannedBrowsingDataFileSystemHelper::Clone() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CannedBrowsingDataFileSystemHelper* clone =
- new CannedBrowsingDataFileSystemHelper(profile_);
-
+ new CannedBrowsingDataFileSystemHelper();
clone->pending_file_system_info_ = pending_file_system_info_;
clone->file_system_info_ = file_system_info_;
return clone;
@@ -242,8 +254,9 @@ void CannedBrowsingDataFileSystemHelper::StartFetching(
completion_callback_.reset(callback);
for (std::vector<PendingFileSystemInfo>::const_iterator
- info = pending_file_system_info_.begin();
- info != pending_file_system_info_.end(); ++info) {
+ info = pending_file_system_info_.begin();
+ info != pending_file_system_info_.end();
+ ++info) {
bool duplicate = false;
for (std::vector<FileSystemInfo>::iterator
file_system = file_system_info_.begin();
@@ -273,16 +286,13 @@ void CannedBrowsingDataFileSystemHelper::StartFetching(
}
pending_file_system_info_.clear();
-// MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this,
-// &CannedBrowsingDataFileSystemHelper::Notify));
-
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
- this, &CannedBrowsingDataFileSystemHelper::Notify));
+ this, &CannedBrowsingDataFileSystemHelper::NotifyOnUIThread));
}
-void CannedBrowsingDataFileSystemHelper::Notify() {
+void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(is_fetching_);
if (completion_callback_ != NULL) {
« no previous file with comments | « chrome/browser/browsing_data_file_system_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698