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

Side by Side Diff: content/browser/download/save_package_browsertest.cc

Issue 2032283002: Remove refcounting from SavePackage. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <memory>
6
5 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
6 #include "content/browser/download/save_package.h" 8 #include "content/browser/download/save_package.h"
7 #include "content/public/test/content_browser_test.h" 9 #include "content/public/test/content_browser_test.h"
8 #include "content/public/test/content_browser_test_utils.h" 10 #include "content/public/test/content_browser_test_utils.h"
9 #include "content/shell/browser/shell.h" 11 #include "content/shell/browser/shell.h"
10 #include "net/test/embedded_test_server/embedded_test_server.h" 12 #include "net/test/embedded_test_server/embedded_test_server.h"
11 13
12 namespace content { 14 namespace content {
13 15
14 const char kTestFile[] = "/simple_page.html"; 16 const char kTestFile[] = "/simple_page.html";
(...skipping 18 matching lines...) Expand all
33 }; 35 };
34 36
35 // Create a SavePackage and delete it without calling Init. 37 // Create a SavePackage and delete it without calling Init.
36 // SavePackage dtor has various asserts/checks that should not fire. 38 // SavePackage dtor has various asserts/checks that should not fire.
37 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) { 39 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) {
38 ASSERT_TRUE(embedded_test_server()->Start()); 40 ASSERT_TRUE(embedded_test_server()->Start());
39 GURL url = embedded_test_server()->GetURL(kTestFile); 41 GURL url = embedded_test_server()->GetURL(kTestFile);
40 NavigateToURL(shell(), url); 42 NavigateToURL(shell(), url);
41 base::FilePath full_file_name, dir; 43 base::FilePath full_file_name, dir;
42 GetDestinationPaths("a", &full_file_name, &dir); 44 GetDestinationPaths("a", &full_file_name, &dir);
43 scoped_refptr<SavePackage> save_package(new SavePackage( 45 std::unique_ptr<SavePackage> save_package(
44 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, 46 new SavePackage(shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML,
45 dir)); 47 full_file_name, dir));
46 } 48 }
47 49
48 // Create a SavePackage, call Cancel, then delete it. 50 // Create a SavePackage, call Cancel, then delete it.
49 // SavePackage dtor has various asserts/checks that should not fire. 51 // SavePackage dtor has various asserts/checks that should not fire.
50 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) { 52 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) {
51 ASSERT_TRUE(embedded_test_server()->Start()); 53 ASSERT_TRUE(embedded_test_server()->Start());
52 GURL url = embedded_test_server()->GetURL(kTestFile); 54 GURL url = embedded_test_server()->GetURL(kTestFile);
53 NavigateToURL(shell(), url); 55 NavigateToURL(shell(), url);
54 base::FilePath full_file_name, dir; 56 base::FilePath full_file_name, dir;
55 GetDestinationPaths("a", &full_file_name, &dir); 57 GetDestinationPaths("a", &full_file_name, &dir);
56 scoped_refptr<SavePackage> save_package(new SavePackage( 58 std::unique_ptr<SavePackage> save_package(
57 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, 59 new SavePackage(shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML,
58 dir)); 60 full_file_name, dir));
59 save_package->Cancel(true); 61 save_package->Cancel(true);
60 } 62 }
61 63
62 } // namespace content 64 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698