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

Unified Diff: content/browser/in_process_webkit/dom_storage_unittest.cc

Issue 9419033: Move creation of BrowserContext objects that live in content to content, instead of depending on th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix memory leaks in tests Created 8 years, 10 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: content/browser/in_process_webkit/dom_storage_unittest.cc
===================================================================
--- content/browser/in_process_webkit/dom_storage_unittest.cc (revision 122721)
+++ content/browser/in_process_webkit/dom_storage_unittest.cc (working copy)
@@ -10,6 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/quota/mock_special_storage_policy.h"
+using content::BrowserContext;
using content::BrowserThread;
using content::BrowserThreadImpl;
@@ -33,10 +34,10 @@
new quota::MockSpecialStoragePolicy;
special_storage_policy->AddSessionOnly(session_only_origin);
- TestBrowserContext browser_context;
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext);
// Create databases for permanent and session-only origins.
- FilePath domstorage_dir = browser_context.GetPath().Append(
+ FilePath domstorage_dir = browser_context->GetPath().Append(
DOMStorageContext::kLocalStorageDirectory);
FilePath::StringType session_only_database(
FILE_PATH_LITERAL("http_www.sessiononly.com_0"));
@@ -55,12 +56,14 @@
ASSERT_EQ(1, file_util::WriteFile(permanent_database_path, ".", 1));
// Inject MockSpecialStoragePolicy into DOMStorageContext.
- browser_context.GetWebKitContext()->dom_storage_context()->
- special_storage_policy_ = special_storage_policy;
+ BrowserContext::GetWebKitContext(browser_context.get())->
+ dom_storage_context()->special_storage_policy_ = special_storage_policy;
- // Delete the WebKitContext before destroying TestBrowserContext. This way the
+ // Delete the TestBrowserContext but own the temp dir. This way the
// temporary data directory stays alive long enough to conduct the test.
- browser_context.webkit_context_ = NULL;
+ ScopedTempDir temp_dir;
+ ignore_result(temp_dir.Set(browser_context->TakePath()));
+ browser_context.reset();
// Run the message loop to ensure that DOMStorageContext gets destroyed.
message_loop_.RunAllPending();
@@ -76,10 +79,10 @@
new quota::MockSpecialStoragePolicy;
special_storage_policy->AddSessionOnly(session_only_origin);
- TestBrowserContext browser_context;
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext);
// Create databases for permanent and session-only origins.
- FilePath domstorage_dir = browser_context.GetPath().Append(
+ FilePath domstorage_dir = browser_context->GetPath().Append(
DOMStorageContext::kLocalStorageDirectory);
FilePath::StringType session_only_database(
FILE_PATH_LITERAL("http_www.sessiononly.com_0"));
@@ -99,7 +102,8 @@
// Inject MockSpecialStoragePolicy into DOMStorageContext.
DOMStorageContext* dom_storage_context =
- browser_context.GetWebKitContext()->dom_storage_context();
+ BrowserContext::GetWebKitContext(browser_context.get())->
+ dom_storage_context();
dom_storage_context->special_storage_policy_ = special_storage_policy;
dom_storage_context->set_clear_local_state_on_exit_(true);
@@ -107,9 +111,11 @@
// Save session state. This should bypass the destruction-time deletion.
dom_storage_context->SaveSessionState();
- // Delete the WebKitContext before destroying TestBrowserContext. This way the
+ // Delete the TestBrowserContext but own the temp dir. This way the
// temporary data directory stays alive long enough to conduct the test.
- browser_context.webkit_context_ = NULL;
+ ScopedTempDir temp_dir;
+ ignore_result(temp_dir.Set(browser_context->TakePath()));
+ browser_context.reset();
// Run the message loop to ensure that DOMStorageContext gets destroyed.
message_loop_.RunAllPending();
« no previous file with comments | « content/browser/in_process_webkit/dom_storage_context.cc ('k') | content/browser/in_process_webkit/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698