OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/indexed_db/indexed_db_internals_ui.h" | 5 #include "content/browser/indexed_db/indexed_db_internals_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 scoped_refptr<IndexedDBContext> context = partition->GetIndexedDBContext(); | 76 scoped_refptr<IndexedDBContext> context = partition->GetIndexedDBContext(); |
77 context->TaskRunner()->PostTask( | 77 context->TaskRunner()->PostTask( |
78 FROM_HERE, | 78 FROM_HERE, |
79 base::Bind(&IndexedDBInternalsUI::GetAllOriginsOnIndexedDBThread, | 79 base::Bind(&IndexedDBInternalsUI::GetAllOriginsOnIndexedDBThread, |
80 base::Unretained(this), | 80 base::Unretained(this), |
81 context, | 81 context, |
82 partition->GetPath())); | 82 partition->GetPath())); |
83 } | 83 } |
84 | 84 |
85 void IndexedDBInternalsUI::GetAllOrigins(const base::ListValue* args) { | 85 void IndexedDBInternalsUI::GetAllOrigins(const base::ListValue* args) { |
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
87 | 87 |
88 BrowserContext* browser_context = | 88 BrowserContext* browser_context = |
89 web_ui()->GetWebContents()->GetBrowserContext(); | 89 web_ui()->GetWebContents()->GetBrowserContext(); |
90 | 90 |
91 BrowserContext::StoragePartitionCallback cb = | 91 BrowserContext::StoragePartitionCallback cb = |
92 base::Bind(&IndexedDBInternalsUI::AddContextFromStoragePartition, | 92 base::Bind(&IndexedDBInternalsUI::AddContextFromStoragePartition, |
93 base::Unretained(this)); | 93 base::Unretained(this)); |
94 BrowserContext::ForEachStoragePartition(browser_context, cb); | 94 BrowserContext::ForEachStoragePartition(browser_context, cb); |
95 } | 95 } |
96 | 96 |
(...skipping 12 matching lines...) Expand all Loading... |
109 BrowserThread::UI, | 109 BrowserThread::UI, |
110 FROM_HERE, | 110 FROM_HERE, |
111 base::Bind(&IndexedDBInternalsUI::OnOriginsReady, | 111 base::Bind(&IndexedDBInternalsUI::OnOriginsReady, |
112 base::Unretained(this), | 112 base::Unretained(this), |
113 base::Passed(&info_list), | 113 base::Passed(&info_list), |
114 is_incognito ? base::FilePath() : context_path)); | 114 is_incognito ? base::FilePath() : context_path)); |
115 } | 115 } |
116 | 116 |
117 void IndexedDBInternalsUI::OnOriginsReady(scoped_ptr<base::ListValue> origins, | 117 void IndexedDBInternalsUI::OnOriginsReady(scoped_ptr<base::ListValue> origins, |
118 const base::FilePath& path) { | 118 const base::FilePath& path) { |
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 119 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
120 web_ui()->CallJavascriptFunction( | 120 web_ui()->CallJavascriptFunction( |
121 "indexeddb.onOriginsReady", *origins, base::StringValue(path.value())); | 121 "indexeddb.onOriginsReady", *origins, base::StringValue(path.value())); |
122 } | 122 } |
123 | 123 |
124 static void FindContext(const base::FilePath& partition_path, | 124 static void FindContext(const base::FilePath& partition_path, |
125 StoragePartition** result_partition, | 125 StoragePartition** result_partition, |
126 scoped_refptr<IndexedDBContextImpl>* result_context, | 126 scoped_refptr<IndexedDBContextImpl>* result_context, |
127 StoragePartition* storage_partition) { | 127 StoragePartition* storage_partition) { |
128 if (storage_partition->GetPath() == partition_path) { | 128 if (storage_partition->GetPath() == partition_path) { |
129 *result_partition = storage_partition; | 129 *result_partition = storage_partition; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 base::Bind(&FindContext, path, &result_partition, context); | 164 base::Bind(&FindContext, path, &result_partition, context); |
165 BrowserContext::ForEachStoragePartition(browser_context, cb); | 165 BrowserContext::ForEachStoragePartition(browser_context, cb); |
166 | 166 |
167 if (!result_partition || !(context->get())) | 167 if (!result_partition || !(context->get())) |
168 return false; | 168 return false; |
169 | 169 |
170 return true; | 170 return true; |
171 } | 171 } |
172 | 172 |
173 void IndexedDBInternalsUI::DownloadOriginData(const base::ListValue* args) { | 173 void IndexedDBInternalsUI::DownloadOriginData(const base::ListValue* args) { |
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
175 | 175 |
176 base::FilePath partition_path; | 176 base::FilePath partition_path; |
177 GURL origin_url; | 177 GURL origin_url; |
178 scoped_refptr<IndexedDBContextImpl> context; | 178 scoped_refptr<IndexedDBContextImpl> context; |
179 if (!GetOriginData(args, &partition_path, &origin_url, &context)) | 179 if (!GetOriginData(args, &partition_path, &origin_url, &context)) |
180 return; | 180 return; |
181 | 181 |
182 DCHECK(context.get()); | 182 DCHECK(context.get()); |
183 context->TaskRunner()->PostTask( | 183 context->TaskRunner()->PostTask( |
184 FROM_HERE, | 184 FROM_HERE, |
185 base::Bind(&IndexedDBInternalsUI::DownloadOriginDataOnIndexedDBThread, | 185 base::Bind(&IndexedDBInternalsUI::DownloadOriginDataOnIndexedDBThread, |
186 base::Unretained(this), | 186 base::Unretained(this), |
187 partition_path, | 187 partition_path, |
188 context, | 188 context, |
189 origin_url)); | 189 origin_url)); |
190 } | 190 } |
191 | 191 |
192 void IndexedDBInternalsUI::ForceCloseOrigin(const base::ListValue* args) { | 192 void IndexedDBInternalsUI::ForceCloseOrigin(const base::ListValue* args) { |
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 193 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
194 | 194 |
195 base::FilePath partition_path; | 195 base::FilePath partition_path; |
196 GURL origin_url; | 196 GURL origin_url; |
197 scoped_refptr<IndexedDBContextImpl> context; | 197 scoped_refptr<IndexedDBContextImpl> context; |
198 if (!GetOriginData(args, &partition_path, &origin_url, &context)) | 198 if (!GetOriginData(args, &partition_path, &origin_url, &context)) |
199 return; | 199 return; |
200 | 200 |
201 context->TaskRunner()->PostTask( | 201 context->TaskRunner()->PostTask( |
202 FROM_HERE, | 202 FROM_HERE, |
203 base::Bind(&IndexedDBInternalsUI::ForceCloseOriginOnIndexedDBThread, | 203 base::Bind(&IndexedDBInternalsUI::ForceCloseOriginOnIndexedDBThread, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 base::StringValue(origin_url.spec()), | 283 base::StringValue(origin_url.spec()), |
284 base::FundamentalValue(static_cast<double>(connection_count))); | 284 base::FundamentalValue(static_cast<double>(connection_count))); |
285 } | 285 } |
286 | 286 |
287 void IndexedDBInternalsUI::OnDownloadDataReady( | 287 void IndexedDBInternalsUI::OnDownloadDataReady( |
288 const base::FilePath& partition_path, | 288 const base::FilePath& partition_path, |
289 const GURL& origin_url, | 289 const GURL& origin_url, |
290 const base::FilePath temp_path, | 290 const base::FilePath temp_path, |
291 const base::FilePath zip_path, | 291 const base::FilePath zip_path, |
292 size_t connection_count) { | 292 size_t connection_count) { |
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 293 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
294 const GURL url = GURL(FILE_PATH_LITERAL("file://") + zip_path.value()); | 294 const GURL url = GURL(FILE_PATH_LITERAL("file://") + zip_path.value()); |
295 BrowserContext* browser_context = | 295 BrowserContext* browser_context = |
296 web_ui()->GetWebContents()->GetBrowserContext(); | 296 web_ui()->GetWebContents()->GetBrowserContext(); |
297 scoped_ptr<DownloadUrlParameters> dl_params( | 297 scoped_ptr<DownloadUrlParameters> dl_params( |
298 DownloadUrlParameters::FromWebContents(web_ui()->GetWebContents(), url)); | 298 DownloadUrlParameters::FromWebContents(web_ui()->GetWebContents(), url)); |
299 DownloadManager* dlm = BrowserContext::GetDownloadManager(browser_context); | 299 DownloadManager* dlm = BrowserContext::GetDownloadManager(browser_context); |
300 | 300 |
301 const GURL referrer(web_ui()->GetWebContents()->GetLastCommittedURL()); | 301 const GURL referrer(web_ui()->GetWebContents()->GetLastCommittedURL()); |
302 dl_params->set_referrer(content::Referrer::SanitizeForRequest( | 302 dl_params->set_referrer(content::Referrer::SanitizeForRequest( |
303 url, content::Referrer(referrer, blink::WebReferrerPolicyDefault))); | 303 url, content::Referrer(referrer, blink::WebReferrerPolicyDefault))); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 item->AddObserver(new FileDeleter(temp_path)); | 371 item->AddObserver(new FileDeleter(temp_path)); |
372 web_ui()->CallJavascriptFunction( | 372 web_ui()->CallJavascriptFunction( |
373 "indexeddb.onOriginDownloadReady", | 373 "indexeddb.onOriginDownloadReady", |
374 base::StringValue(partition_path.value()), | 374 base::StringValue(partition_path.value()), |
375 base::StringValue(origin_url.spec()), | 375 base::StringValue(origin_url.spec()), |
376 base::FundamentalValue(static_cast<double>(connection_count))); | 376 base::FundamentalValue(static_cast<double>(connection_count))); |
377 } | 377 } |
378 | 378 |
379 } // namespace content | 379 } // namespace content |
OLD | NEW |