| Index: content/browser/in_process_webkit/dom_storage_unittest.cc
|
| ===================================================================
|
| --- content/browser/in_process_webkit/dom_storage_unittest.cc (revision 122416)
|
| +++ 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();
|
|
|
|
|