Chromium Code Reviews| 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_indexed_db_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "content/public/browser/browser_context.h" |
|
awong
2012/09/10 21:55:21
Why do you need browser_context.h?
alecflett
2012/09/10 23:14:55
oops, don't now.
| |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/indexed_db_context.h" | 18 #include "content/public/browser/indexed_db_context.h" |
| 19 #include "webkit/database/database_util.h" | 19 #include "webkit/database/database_util.h" |
| 20 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
| 21 | 21 |
| 22 using content::BrowserContext; | 22 using content::BrowserContext; |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 using content::IndexedDBContext; | 24 using content::IndexedDBContext; |
| 25 using webkit_database::DatabaseUtil; | 25 using webkit_database::DatabaseUtil; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { | 29 class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { |
| 30 public: | 30 public: |
| 31 explicit BrowsingDataIndexedDBHelperImpl(Profile* profile); | 31 explicit BrowsingDataIndexedDBHelperImpl(IndexedDBContext* context); |
|
awong
2012/09/10 21:55:21
Call this indexed_db_context. Yeah it's long. :(
alecflett
2012/09/10 23:14:55
Done.
| |
| 32 | 32 |
| 33 virtual void StartFetching( | 33 virtual void StartFetching( |
| 34 const base::Callback<void(const std::list<IndexedDBInfo>&)>& | 34 const base::Callback<void(const std::list<IndexedDBInfo>&)>& |
| 35 callback) OVERRIDE; | 35 callback) OVERRIDE; |
| 36 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; | 36 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 virtual ~BrowsingDataIndexedDBHelperImpl(); | 39 virtual ~BrowsingDataIndexedDBHelperImpl(); |
| 40 | 40 |
| 41 // Enumerates all indexed database files in the WEBKIT thread. | 41 // Enumerates all indexed database files in the WEBKIT thread. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 61 // Indicates whether or not we're currently fetching information: | 61 // Indicates whether or not we're currently fetching information: |
| 62 // it's true when StartFetching() is called in the UI thread, and it's reset | 62 // it's true when StartFetching() is called in the UI thread, and it's reset |
| 63 // after we notified the callback in the UI thread. | 63 // after we notified the callback in the UI thread. |
| 64 // This only mutates on the UI thread. | 64 // This only mutates on the UI thread. |
| 65 bool is_fetching_; | 65 bool is_fetching_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(BrowsingDataIndexedDBHelperImpl); | 67 DISALLOW_COPY_AND_ASSIGN(BrowsingDataIndexedDBHelperImpl); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 BrowsingDataIndexedDBHelperImpl::BrowsingDataIndexedDBHelperImpl( | 70 BrowsingDataIndexedDBHelperImpl::BrowsingDataIndexedDBHelperImpl( |
| 71 Profile* profile) | 71 IndexedDBContext* context) |
| 72 : indexed_db_context_(BrowserContext::GetIndexedDBContext(profile)), | 72 : indexed_db_context_(context), |
| 73 is_fetching_(false) { | 73 is_fetching_(false) { |
| 74 DCHECK(indexed_db_context_.get()); | 74 DCHECK(indexed_db_context_.get()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 BrowsingDataIndexedDBHelperImpl::~BrowsingDataIndexedDBHelperImpl() { | 77 BrowsingDataIndexedDBHelperImpl::~BrowsingDataIndexedDBHelperImpl() { |
| 78 } | 78 } |
| 79 | 79 |
| 80 void BrowsingDataIndexedDBHelperImpl::StartFetching( | 80 void BrowsingDataIndexedDBHelperImpl::StartFetching( |
| 81 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { | 81 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 base::Time last_modified) | 144 base::Time last_modified) |
| 145 : origin(origin), | 145 : origin(origin), |
| 146 size(size), | 146 size(size), |
| 147 last_modified(last_modified) { | 147 last_modified(last_modified) { |
| 148 } | 148 } |
| 149 | 149 |
| 150 BrowsingDataIndexedDBHelper::IndexedDBInfo::~IndexedDBInfo() {} | 150 BrowsingDataIndexedDBHelper::IndexedDBInfo::~IndexedDBInfo() {} |
| 151 | 151 |
| 152 // static | 152 // static |
| 153 BrowsingDataIndexedDBHelper* BrowsingDataIndexedDBHelper::Create( | 153 BrowsingDataIndexedDBHelper* BrowsingDataIndexedDBHelper::Create( |
| 154 Profile* profile) { | 154 IndexedDBContext* context) { |
| 155 return new BrowsingDataIndexedDBHelperImpl(profile); | 155 return new BrowsingDataIndexedDBHelperImpl(context); |
| 156 } | 156 } |
| 157 | 157 |
| 158 CannedBrowsingDataIndexedDBHelper:: | 158 CannedBrowsingDataIndexedDBHelper:: |
| 159 PendingIndexedDBInfo::PendingIndexedDBInfo(const GURL& origin, | 159 PendingIndexedDBInfo::PendingIndexedDBInfo(const GURL& origin, |
| 160 const string16& name) | 160 const string16& name) |
| 161 : origin(origin), | 161 : origin(origin), |
| 162 name(name) { | 162 name(name) { |
| 163 } | 163 } |
| 164 | 164 |
| 165 CannedBrowsingDataIndexedDBHelper:: | 165 CannedBrowsingDataIndexedDBHelper:: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 } | 254 } |
| 255 | 255 |
| 256 void CannedBrowsingDataIndexedDBHelper::NotifyInUIThread() { | 256 void CannedBrowsingDataIndexedDBHelper::NotifyInUIThread() { |
| 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 258 DCHECK(is_fetching_); | 258 DCHECK(is_fetching_); |
| 259 | 259 |
| 260 completion_callback_.Run(indexed_db_info_); | 260 completion_callback_.Run(indexed_db_info_); |
| 261 completion_callback_.Reset(); | 261 completion_callback_.Reset(); |
| 262 is_fetching_ = false; | 262 is_fetching_ = false; |
| 263 } | 263 } |
| OLD | NEW |