Index: chrome/browser/browsing_data_database_helper.h |
diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h |
index af506c0c458c32ac99c95f2f31b16a3509274c3a..fa1d069923a59cf11e64a575eb821965920a3f4b 100644 |
--- a/chrome/browser/browsing_data_database_helper.h |
+++ b/chrome/browser/browsing_data_database_helper.h |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -11,14 +11,15 @@ |
#include "base/callback.h" |
#include "base/scoped_ptr.h" |
+#include "base/synchronization/lock.h" |
#include "chrome/common/url_constants.h" |
#include "googleurl/src/gurl.h" |
#include "webkit/database/database_tracker.h" |
class Profile; |
-// This class fetches database information in the FILE thread, and notifies the |
-// UI thread upon completion. |
+// This class fetches database information in the WEBKIT thread, and notifies |
+// the UI thread upon completion. |
// A client of this class need to call StartFetching from the UI thread to |
// initiate the flow, and it'll be notified by the callback in its UI |
// thread at some later point. |
@@ -63,7 +64,7 @@ class BrowsingDataDatabaseHelper |
// This must be called only in the UI thread. |
virtual void CancelNotification(); |
- // Requests a single database to be deleted in the FILE thread. This must be |
+ // Requests a single database to be deleted in the WEBKIT thread. This must be |
// called in the UI thread. |
virtual void DeleteDatabase(const std::string& origin, |
const std::string& name); |
@@ -72,21 +73,11 @@ class BrowsingDataDatabaseHelper |
friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>; |
virtual ~BrowsingDataDatabaseHelper(); |
- // This only mutates in the FILE thread. |
- std::vector<DatabaseInfo> database_info_; |
- |
- private: |
- // Enumerates all databases. This must be called in the FILE thread. |
- void FetchDatabaseInfoInFileThread(); |
- |
// Notifies the completion callback. This must be called in the UI thread. |
void NotifyInUIThread(); |
- // Delete a single database file. This must be called in the FILE thread. |
- void DeleteDatabaseInFileThread(const std::string& origin, |
- const std::string& name); |
- |
- scoped_refptr<webkit_database::DatabaseTracker> tracker_; |
+ // This only mutates in the WEBKIT thread. |
+ std::vector<DatabaseInfo> database_info_; |
// This only mutates on the UI thread. |
scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type > |
@@ -98,6 +89,16 @@ class BrowsingDataDatabaseHelper |
// This only mutates on the UI thread. |
bool is_fetching_; |
+ private: |
+ // Enumerates all databases. This must be called in the WEBKIT thread. |
+ void FetchDatabaseInfoInWebKitThread(); |
+ |
+ // Delete a single database file. This must be called in the WEBKIT thread. |
+ void DeleteDatabaseInWebKitThread(const std::string& origin, |
+ const std::string& name); |
+ |
+ scoped_refptr<webkit_database::DatabaseTracker> tracker_; |
+ |
DISALLOW_COPY_AND_ASSIGN(BrowsingDataDatabaseHelper); |
}; |
@@ -126,8 +127,29 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { |
virtual void CancelNotification() {} |
private: |
+ struct PendingDatabaseInfo { |
+ PendingDatabaseInfo(); |
+ PendingDatabaseInfo(const GURL& origin, |
+ const std::string& name, |
+ const std::string& description); |
+ ~PendingDatabaseInfo(); |
+ |
+ GURL origin; |
+ std::string name; |
+ std::string description; |
+ }; |
+ |
virtual ~CannedBrowsingDataDatabaseHelper() {} |
+ // Converts the pending database info structs to database info structs. |
+ void ConvertInfoInWebKitThread(); |
+ |
+ // Used to protect access to pending_database_info_. |
+ mutable base::Lock lock_; |
+ |
+ // This may mutate on WEBKIT and UI threads. |
+ std::vector<PendingDatabaseInfo> pending_database_info_; |
+ |
DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper); |
}; |