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

Side by Side Diff: content/browser/indexed_db/indexed_db_internals_ui.cc

Issue 1757693002: Reduce use of DatabaseIdentifier in Indexed DB entry points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "content/browser/indexed_db/indexed_db_context_impl.h" 15 #include "content/browser/indexed_db/indexed_db_context_impl.h"
16 #include "content/grit/content_resources.h" 16 #include "content/grit/content_resources.h"
17 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/download_manager.h" 19 #include "content/public/browser/download_manager.h"
20 #include "content/public/browser/download_url_parameters.h" 20 #include "content/public/browser/download_url_parameters.h"
21 #include "content/public/browser/storage_partition.h" 21 #include "content/public/browser/storage_partition.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_ui.h" 23 #include "content/public/browser/web_ui.h"
24 #include "content/public/browser/web_ui_data_source.h" 24 #include "content/public/browser/web_ui_data_source.h"
25 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
26 #include "storage/common/database/database_identifier.h"
27 #include "third_party/zlib/google/zip.h" 26 #include "third_party/zlib/google/zip.h"
28 #include "ui/base/text/bytes_formatting.h" 27 #include "ui/base/text/bytes_formatting.h"
29 28
30 namespace content { 29 namespace content {
31 30
32 namespace { 31 namespace {
33 32
34 bool AllowWhitelistedPaths(const std::vector<base::FilePath>& allowed_paths, 33 bool AllowWhitelistedPaths(const std::vector<base::FilePath>& allowed_paths,
35 const base::FilePath& candidate_path) { 34 const base::FilePath& candidate_path) {
36 for (const base::FilePath& allowed_path : allowed_paths) { 35 for (const base::FilePath& allowed_path : allowed_paths) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 size_t connection_count = context->GetConnectionCount(origin_url); 225 size_t connection_count = context->GetConnectionCount(origin_url);
227 226
228 base::ScopedTempDir temp_dir; 227 base::ScopedTempDir temp_dir;
229 if (!temp_dir.CreateUniqueTempDir()) 228 if (!temp_dir.CreateUniqueTempDir())
230 return; 229 return;
231 230
232 // This will get cleaned up on the File thread after the download 231 // This will get cleaned up on the File thread after the download
233 // has completed. 232 // has completed.
234 base::FilePath temp_path = temp_dir.Take(); 233 base::FilePath temp_path = temp_dir.Take();
235 234
236 std::string origin_id = storage::GetIdentifierFromOrigin(origin_url);
237 base::FilePath zip_path = 235 base::FilePath zip_path =
238 temp_path.AppendASCII(origin_id).AddExtension(FILE_PATH_LITERAL("zip")); 236 temp_path.Append(IndexedDBContextImpl::GetLevelDBFileName(origin_url))
jsbell 2016/03/02 17:52:56 Using GetIdentifierFromOrigin here would be totall
michaeln 2016/03/02 23:51:33 I don't have a strong opinion. Is this filename se
jsbell 2016/03/03 01:11:24 Yes, seen by the user, it becomes a file in "Downl
237 .AddExtension(FILE_PATH_LITERAL("zip"));
239 238
240 std::vector<base::FilePath> paths = context->GetStoragePaths(origin_url); 239 std::vector<base::FilePath> paths = context->GetStoragePaths(origin_url);
241 zip::ZipWithFilterCallback(context->data_path(), zip_path, 240 zip::ZipWithFilterCallback(context->data_path(), zip_path,
242 base::Bind(AllowWhitelistedPaths, paths)); 241 base::Bind(AllowWhitelistedPaths, paths));
243 242
244 BrowserThread::PostTask(BrowserThread::UI, 243 BrowserThread::PostTask(BrowserThread::UI,
245 FROM_HERE, 244 FROM_HERE,
246 base::Bind(&IndexedDBInternalsUI::OnDownloadDataReady, 245 base::Bind(&IndexedDBInternalsUI::OnDownloadDataReady,
247 base::Unretained(this), 246 base::Unretained(this),
248 partition_path, 247 partition_path,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 370
372 item->AddObserver(new FileDeleter(temp_path)); 371 item->AddObserver(new FileDeleter(temp_path));
373 web_ui()->CallJavascriptFunction( 372 web_ui()->CallJavascriptFunction(
374 "indexeddb.onOriginDownloadReady", 373 "indexeddb.onOriginDownloadReady",
375 base::StringValue(partition_path.value()), 374 base::StringValue(partition_path.value()),
376 base::StringValue(origin_url.spec()), 375 base::StringValue(origin_url.spec()),
377 base::FundamentalValue(static_cast<double>(connection_count))); 376 base::FundamentalValue(static_cast<double>(connection_count)));
378 } 377 }
379 378
380 } // namespace content 379 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698