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

Side by Side Diff: chrome/browser/extensions/process_manager_browsertest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "extensions/browser/process_manager.h" 5 #include <stddef.h>
6 6
7 #include <stddef.h> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/run_loop.h" 12 #include "base/run_loop.h"
14 #include "chrome/browser/extensions/browser_action_test_util.h" 13 #include "chrome/browser/extensions/browser_action_test_util.h"
15 #include "chrome/browser/extensions/extension_browsertest.h" 14 #include "chrome/browser/extensions/extension_browsertest.h"
16 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/test_extension_dir.h" 16 #include "chrome/browser/extensions/test_extension_dir.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/extensions/extension_process_policy.h" 18 #include "chrome/common/extensions/extension_process_policy.h"
20 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/render_frame_host.h" 22 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
25 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
26 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
26 #include "extensions/browser/process_manager.h"
27 #include "extensions/common/value_builder.h" 27 #include "extensions/common/value_builder.h"
28 #include "extensions/test/background_page_watcher.h" 28 #include "extensions/test/background_page_watcher.h"
29 #include "net/dns/mock_host_resolver.h" 29 #include "net/dns/mock_host_resolver.h"
30 #include "net/test/embedded_test_server/embedded_test_server.h" 30 #include "net/test/embedded_test_server/embedded_test_server.h"
31 31
32 namespace extensions { 32 namespace extensions {
33 33
34 namespace { 34 namespace {
35 35
36 void AddFrameToSet(std::set<content::RenderFrameHost*>* frames, 36 void AddFrameToSet(std::set<content::RenderFrameHost*>* frames,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 }; 88 };
89 89
90 // Exists as a browser test because ExtensionHosts are hard to create without 90 // Exists as a browser test because ExtensionHosts are hard to create without
91 // a real browser. 91 // a real browser.
92 class ProcessManagerBrowserTest : public ExtensionBrowserTest { 92 class ProcessManagerBrowserTest : public ExtensionBrowserTest {
93 public: 93 public:
94 // Create an extension with web-accessible frames and an optional background 94 // Create an extension with web-accessible frames and an optional background
95 // page. 95 // page.
96 const Extension* CreateExtension(const std::string& name, 96 const Extension* CreateExtension(const std::string& name,
97 bool has_background_process) { 97 bool has_background_process) {
98 scoped_ptr<TestExtensionDir> dir(new TestExtensionDir()); 98 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir());
99 99
100 DictionaryBuilder manifest; 100 DictionaryBuilder manifest;
101 manifest.Set("name", name) 101 manifest.Set("name", name)
102 .Set("version", "1") 102 .Set("version", "1")
103 .Set("manifest_version", 2) 103 .Set("manifest_version", 2)
104 // To allow ExecuteScript* to work. 104 // To allow ExecuteScript* to work.
105 .Set("content_security_policy", 105 .Set("content_security_policy",
106 "script-src 'self' 'unsafe-eval'; object-src 'self'") 106 "script-src 'self' 'unsafe-eval'; object-src 'self'")
107 .Set("sandbox", 107 .Set("sandbox",
108 DictionaryBuilder() 108 DictionaryBuilder()
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 size_t IfExtensionsIsolated(size_t if_enabled, size_t if_disabled) { 159 size_t IfExtensionsIsolated(size_t if_enabled, size_t if_disabled) {
160 return content::AreAllSitesIsolatedForTesting() || 160 return content::AreAllSitesIsolatedForTesting() ||
161 IsIsolateExtensionsEnabled() 161 IsIsolateExtensionsEnabled()
162 ? if_enabled 162 ? if_enabled
163 : if_disabled; 163 : if_disabled;
164 } 164 }
165 165
166 private: 166 private:
167 std::vector<scoped_ptr<TestExtensionDir>> temp_dirs_; 167 std::vector<std::unique_ptr<TestExtensionDir>> temp_dirs_;
168 }; 168 };
169 169
170 // Test that basic extension loading creates the appropriate ExtensionHosts 170 // Test that basic extension loading creates the appropriate ExtensionHosts
171 // and background pages. 171 // and background pages.
172 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, 172 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
173 ExtensionHostCreation) { 173 ExtensionHostCreation) {
174 ProcessManager* pm = ProcessManager::Get(profile()); 174 ProcessManager* pm = ProcessManager::Get(profile());
175 175
176 // We start with no background hosts. 176 // We start with no background hosts.
177 ASSERT_EQ(0u, pm->background_hosts().size()); 177 ASSERT_EQ(0u, pm->background_hosts().size());
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 pm->OnNetworkRequestDone(frame_host, 1); 521 pm->OnNetworkRequestDone(frame_host, 1);
522 EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get())); 522 EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get()));
523 523
524 // Simulate only a request completion for this ID and ensure it doesn't result 524 // Simulate only a request completion for this ID and ensure it doesn't result
525 // in keepalive decrement. 525 // in keepalive decrement.
526 pm->OnNetworkRequestDone(frame_host, 2); 526 pm->OnNetworkRequestDone(frame_host, 2);
527 EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get())); 527 EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get()));
528 } 528 }
529 529
530 } // namespace extensions 530 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698