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

Unified Diff: chrome/browser/extensions/api/content_settings/content_settings_apitest.cc

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
index 1447af8ad9e40e7a03c094740c30c2a0dc9adcda..3867baa3e67664580a55279058135f2109d0f274 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_apitest.cc
@@ -2,17 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind_helpers.h"
#include "base/location.h"
+#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "build/build_config.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/lifetime/keep_alive_types.h"
+#include "chrome/browser/lifetime/scoped_keep_alive.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
@@ -27,14 +30,6 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/test_extension_registry_observer.h"
-namespace {
-
-void ReleaseBrowserProcessModule() {
- g_browser_process->ReleaseModule();
-}
-
-} // namespace
-
namespace extensions {
class ExtensionContentSettingsApiTest : public ExtensionApiTest {
@@ -53,17 +48,19 @@ class ExtensionContentSettingsApiTest : public ExtensionApiTest {
// save the profile.
profile_ = browser()->profile();
- // Closing the last browser window also releases a module reference. Make
+ // Closing the last browser window also releases a KeepAlive. Make
// sure it's not the last one, so the message loop doesn't quit
// unexpectedly.
- g_browser_process->AddRefModule();
+ keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::BROWSER,
+ KeepAliveRestartOption::DISABLED));
}
void TearDownOnMainThread() override {
- // ReleaseBrowserProcessModule() needs to be called in a message loop, so we
- // post a task to do it, then run the message loop.
+ // BrowserProcess::Shutdown() needs to be called in a message loop, so we
+ // post a task to release the keep alive, then run the message loop.
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&ReleaseBrowserProcessModule));
+ FROM_HERE, base::Bind(&scoped_ptr<ScopedKeepAlive>::reset,
+ base::Unretained(&keep_alive_), nullptr));
content::RunAllPendingInMessageLoop();
ExtensionApiTest::TearDownOnMainThread();
@@ -240,6 +237,7 @@ class ExtensionContentSettingsApiTest : public ExtensionApiTest {
private:
Profile* profile_;
+ scoped_ptr<ScopedKeepAlive> keep_alive_;
};
// http://crbug.com/177163
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/extensions/api/preference/preference_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698