| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_indexed_db_helper.h" | 5 #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { | 102 void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { |
| 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| 104 file_util::FileEnumerator file_enumerator( | 104 file_util::FileEnumerator file_enumerator( |
| 105 profile_->GetWebKitContext()->data_path().Append( | 105 profile_->GetWebKitContext()->data_path().Append( |
| 106 IndexedDBContext::kIndexedDBDirectory), | 106 IndexedDBContext::kIndexedDBDirectory), |
| 107 false, file_util::FileEnumerator::FILES); | 107 false, file_util::FileEnumerator::FILES); |
| 108 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); | 108 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); |
| 109 file_path = file_enumerator.Next()) { | 109 file_path = file_enumerator.Next()) { |
| 110 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) { | 110 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) { |
| 111 std::string name; | 111 WebSecurityOrigin web_security_origin = |
| 112 WebSecurityOrigin web_security_origin; | 112 WebKit::WebSecurityOrigin::createFromDatabaseIdentifier( |
| 113 if (!IndexedDBContext::SplitIndexedDBFileName( | 113 webkit_glue::FilePathToWebString(file_path.BaseName())); |
| 114 file_path, &name, &web_security_origin)) { | |
| 115 // Could not parse file name. | |
| 116 continue; | |
| 117 } | |
| 118 if (EqualsASCII(web_security_origin.protocol(), | 114 if (EqualsASCII(web_security_origin.protocol(), |
| 119 chrome::kExtensionScheme)) { | 115 chrome::kExtensionScheme)) { |
| 120 // Extension state is not considered browsing data. | 116 // Extension state is not considered browsing data. |
| 121 continue; | 117 continue; |
| 122 } | 118 } |
| 123 base::PlatformFileInfo file_info; | 119 base::PlatformFileInfo file_info; |
| 124 bool ret = file_util::GetFileInfo(file_path, &file_info); | 120 bool ret = file_util::GetFileInfo(file_path, &file_info); |
| 125 if (ret) { | 121 if (ret) { |
| 126 indexed_db_info_.push_back(IndexedDBInfo( | 122 indexed_db_info_.push_back(IndexedDBInfo( |
| 127 web_security_origin.protocol().utf8(), | 123 web_security_origin.protocol().utf8(), |
| 128 web_security_origin.host().utf8(), | 124 web_security_origin.host().utf8(), |
| 129 web_security_origin.port(), | 125 web_security_origin.port(), |
| 130 web_security_origin.databaseIdentifier().utf8(), | 126 web_security_origin.databaseIdentifier().utf8(), |
| 131 web_security_origin.toString().utf8(), | 127 web_security_origin.toString().utf8(), |
| 132 name, | |
| 133 file_path, | 128 file_path, |
| 134 file_info.size, | 129 file_info.size, |
| 135 file_info.last_modified)); | 130 file_info.last_modified)); |
| 136 } | 131 } |
| 137 } | 132 } |
| 138 } | 133 } |
| 139 | 134 |
| 140 BrowserThread::PostTask( | 135 BrowserThread::PostTask( |
| 141 BrowserThread::UI, FROM_HERE, | 136 BrowserThread::UI, FROM_HERE, |
| 142 NewRunnableMethod( | 137 NewRunnableMethod( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 169 return new BrowsingDataIndexedDBHelperImpl(profile); | 164 return new BrowsingDataIndexedDBHelperImpl(profile); |
| 170 } | 165 } |
| 171 | 166 |
| 172 CannedBrowsingDataIndexedDBHelper::CannedBrowsingDataIndexedDBHelper( | 167 CannedBrowsingDataIndexedDBHelper::CannedBrowsingDataIndexedDBHelper( |
| 173 Profile* profile) | 168 Profile* profile) |
| 174 : profile_(profile) { | 169 : profile_(profile) { |
| 175 DCHECK(profile); | 170 DCHECK(profile); |
| 176 } | 171 } |
| 177 | 172 |
| 178 void CannedBrowsingDataIndexedDBHelper::AddIndexedDB( | 173 void CannedBrowsingDataIndexedDBHelper::AddIndexedDB( |
| 179 const GURL& origin, const string16& name, const string16& description) { | 174 const GURL& origin, const string16& description) { |
| 180 WebSecurityOrigin web_security_origin = | 175 WebSecurityOrigin web_security_origin = |
| 181 WebSecurityOrigin::createFromString( | 176 WebSecurityOrigin::createFromString( |
| 182 UTF8ToUTF16(origin.spec())); | 177 UTF8ToUTF16(origin.spec())); |
| 183 std::string security_origin(web_security_origin.toString().utf8()); | 178 std::string security_origin(web_security_origin.toString().utf8()); |
| 184 | 179 |
| 185 for (std::vector<IndexedDBInfo>::iterator | 180 for (std::vector<IndexedDBInfo>::iterator |
| 186 indexed_db = indexed_db_info_.begin(); | 181 indexed_db = indexed_db_info_.begin(); |
| 187 indexed_db != indexed_db_info_.end(); ++indexed_db) { | 182 indexed_db != indexed_db_info_.end(); ++indexed_db) { |
| 188 if (indexed_db->origin == security_origin) | 183 if (indexed_db->origin == security_origin) |
| 189 return; | 184 return; |
| 190 } | 185 } |
| 191 | 186 |
| 192 indexed_db_info_.push_back(IndexedDBInfo( | 187 indexed_db_info_.push_back(IndexedDBInfo( |
| 193 web_security_origin.protocol().utf8(), | 188 web_security_origin.protocol().utf8(), |
| 194 web_security_origin.host().utf8(), | 189 web_security_origin.host().utf8(), |
| 195 web_security_origin.port(), | 190 web_security_origin.port(), |
| 196 web_security_origin.databaseIdentifier().utf8(), | 191 web_security_origin.databaseIdentifier().utf8(), |
| 197 security_origin, | 192 security_origin, |
| 198 UTF16ToUTF8(name), | |
| 199 profile_->GetWebKitContext()->indexed_db_context()-> | 193 profile_->GetWebKitContext()->indexed_db_context()-> |
| 200 GetIndexedDBFilePath(name, web_security_origin), | 194 GetIndexedDBFilePath(web_security_origin.databaseIdentifier()), |
| 201 0, | 195 0, |
| 202 base::Time())); | 196 base::Time())); |
| 203 } | 197 } |
| 204 | 198 |
| 205 void CannedBrowsingDataIndexedDBHelper::Reset() { | 199 void CannedBrowsingDataIndexedDBHelper::Reset() { |
| 206 indexed_db_info_.clear(); | 200 indexed_db_info_.clear(); |
| 207 } | 201 } |
| 208 | 202 |
| 209 bool CannedBrowsingDataIndexedDBHelper::empty() const { | 203 bool CannedBrowsingDataIndexedDBHelper::empty() const { |
| 210 return indexed_db_info_.empty(); | 204 return indexed_db_info_.empty(); |
| 211 } | 205 } |
| 212 | 206 |
| 213 void CannedBrowsingDataIndexedDBHelper::StartFetching( | 207 void CannedBrowsingDataIndexedDBHelper::StartFetching( |
| 214 Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) { | 208 Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) { |
| 215 callback->Run(indexed_db_info_); | 209 callback->Run(indexed_db_info_); |
| 216 delete callback; | 210 delete callback; |
| 217 } | 211 } |
| 218 | 212 |
| 219 CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {} | 213 CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {} |
| OLD | NEW |