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

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

Issue 2860593003: Refactoring DownloadManager::DownloadURL to add proper annotation. (Closed)
Patch Set: Comment addressed. Created 3 years, 6 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 "net/traffic_annotation/network_traffic_annotation.h"
26 #include "storage/common/database/database_identifier.h" 27 #include "storage/common/database/database_identifier.h"
27 #include "third_party/zlib/google/zip.h" 28 #include "third_party/zlib/google/zip.h"
28 #include "ui/base/text/bytes_formatting.h" 29 #include "ui/base/text/bytes_formatting.h"
29 #include "url/origin.h" 30 #include "url/origin.h"
30 31
31 using url::Origin; 32 using url::Origin;
32 33
33 namespace content { 34 namespace content {
34 35
35 namespace { 36 namespace {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 293
293 // This is how to watch for the download to finish: first wait for it 294 // This is how to watch for the download to finish: first wait for it
294 // to start, then attach a DownloadItem::Observer to observe the 295 // to start, then attach a DownloadItem::Observer to observe the
295 // state change to the finished state. 296 // state change to the finished state.
296 dl_params->set_callback(base::Bind(&IndexedDBInternalsUI::OnDownloadStarted, 297 dl_params->set_callback(base::Bind(&IndexedDBInternalsUI::OnDownloadStarted,
297 base::Unretained(this), partition_path, 298 base::Unretained(this), partition_path,
298 origin, temp_path, connection_count)); 299 origin, temp_path, connection_count));
299 300
300 BrowserContext* context = web_contents->GetBrowserContext(); 301 BrowserContext* context = web_contents->GetBrowserContext();
301 BrowserContext::GetDownloadManager(context)->DownloadUrl( 302 BrowserContext::GetDownloadManager(context)->DownloadUrl(
302 std::move(dl_params)); 303 std::move(dl_params), NO_TRAFFIC_ANNOTATION_YET);
303 } 304 }
304 305
305 // The entire purpose of this class is to delete the temp file after 306 // The entire purpose of this class is to delete the temp file after
306 // the download is complete. 307 // the download is complete.
307 class FileDeleter : public DownloadItem::Observer { 308 class FileDeleter : public DownloadItem::Observer {
308 public: 309 public:
309 explicit FileDeleter(const base::FilePath& temp_dir) : temp_dir_(temp_dir) {} 310 explicit FileDeleter(const base::FilePath& temp_dir) : temp_dir_(temp_dir) {}
310 ~FileDeleter() override; 311 ~FileDeleter() override;
311 312
312 void OnDownloadUpdated(DownloadItem* download) override; 313 void OnDownloadUpdated(DownloadItem* download) override;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 357 }
357 358
358 item->AddObserver(new FileDeleter(temp_path)); 359 item->AddObserver(new FileDeleter(temp_path));
359 web_ui()->CallJavascriptFunctionUnsafe( 360 web_ui()->CallJavascriptFunctionUnsafe(
360 "indexeddb.onOriginDownloadReady", base::Value(partition_path.value()), 361 "indexeddb.onOriginDownloadReady", base::Value(partition_path.value()),
361 base::Value(origin.Serialize()), 362 base::Value(origin.Serialize()),
362 base::Value(static_cast<double>(connection_count))); 363 base::Value(static_cast<double>(connection_count)));
363 } 364 }
364 365
365 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_message_filter.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698