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

Side by Side Diff: content/browser/dom_storage/dom_storage_browsertest.cc

Issue 2861473002: Clear up session only storage on localstorage shutdown (Closed)
Patch Set: address comments Created 3 years, 7 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
« no previous file with comments | « no previous file | content/browser/dom_storage/dom_storage_context_wrapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
8 #include "content/browser/dom_storage/local_storage_context_mojo.h" 8 #include "content/browser/dom_storage/local_storage_context_mojo.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/dom_storage/dom_storage_types.h" 10 #include "content/common/dom_storage/dom_storage_types.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void SetUpCommandLine(base::CommandLine* command_line) override { 47 void SetUpCommandLine(base::CommandLine* command_line) override {
48 ContentBrowserTest::SetUpCommandLine(command_line); 48 ContentBrowserTest::SetUpCommandLine(command_line);
49 command_line->AppendSwitch(switches::kMojoLocalStorage); 49 command_line->AppendSwitch(switches::kMojoLocalStorage);
50 } 50 }
51 51
52 LocalStorageContextMojo* context() { 52 LocalStorageContextMojo* context() {
53 return static_cast<DOMStorageContextWrapper*>( 53 return static_cast<DOMStorageContextWrapper*>(
54 BrowserContext::GetDefaultStoragePartition( 54 BrowserContext::GetDefaultStoragePartition(
55 shell()->web_contents()->GetBrowserContext()) 55 shell()->web_contents()->GetBrowserContext())
56 ->GetDOMStorageContext()) 56 ->GetDOMStorageContext())
57 ->mojo_state_.get(); 57 ->mojo_state_;
58 } 58 }
59 59
60 void EnsureConnected() { 60 void EnsureConnected() {
61 base::RunLoop run_loop; 61 base::RunLoop run_loop;
62 context()->RunWhenConnected(run_loop.QuitClosure()); 62 BrowserThread::PostTask(
63 BrowserThread::IO, FROM_HERE,
64 base::BindOnce(
65 &LocalStorageContextMojo::RunWhenConnected,
66 base::Unretained(context()),
67 base::BindOnce(base::IgnoreResult(&base::TaskRunner::PostTask),
68 base::ThreadTaskRunnerHandle::Get(), FROM_HERE,
69 run_loop.QuitClosure())));
63 run_loop.Run(); 70 run_loop.Run();
64 } 71 }
65
66 void Flush() {
67 // Process any tasks that are currently queued, to ensure
68 // LevelDBWrapperImpl methods get called.
69 base::RunLoop().RunUntilIdle();
70 // And finally flush all the now queued up changes to leveldb.
71 context()->Flush();
72 base::RunLoop().RunUntilIdle();
73 }
74 }; 72 };
75 73
76 static const bool kIncognito = true; 74 static const bool kIncognito = true;
77 static const bool kNotIncognito = false; 75 static const bool kNotIncognito = false;
78 76
79 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) { 77 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) {
80 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito); 78 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
81 } 79 }
82 80
83 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheckIncognito) { 81 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheckIncognito) {
(...skipping 18 matching lines...) Expand all
102 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito); 100 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
103 } 101 }
104 102
105 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheckIncognito) { 103 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheckIncognito) {
106 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito); 104 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito);
107 } 105 }
108 106
109 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, PRE_DataPersists) { 107 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, PRE_DataPersists) {
110 EnsureConnected(); 108 EnsureConnected();
111 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito); 109 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito);
112 Flush();
113 } 110 }
114 111
115 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, MAYBE_DataPersists) { 112 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, MAYBE_DataPersists) {
116 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); 113 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito);
117 } 114 }
118 115
119 class DOMStorageMigrationBrowserTest : public DOMStorageBrowserTest { 116 class DOMStorageMigrationBrowserTest : public DOMStorageBrowserTest {
120 public: 117 public:
121 void SetUpCommandLine(base::CommandLine* command_line) override { 118 void SetUpCommandLine(base::CommandLine* command_line) override {
122 ContentBrowserTest::SetUpCommandLine(command_line); 119 ContentBrowserTest::SetUpCommandLine(command_line);
(...skipping 13 matching lines...) Expand all
136 #if defined(OS_ANDROID) 133 #if defined(OS_ANDROID)
137 #define MAYBE_DataMigrates DISABLED_DataMigrates 134 #define MAYBE_DataMigrates DISABLED_DataMigrates
138 #else 135 #else
139 #define MAYBE_DataMigrates DataMigrates 136 #define MAYBE_DataMigrates DataMigrates
140 #endif 137 #endif
141 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) { 138 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) {
142 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); 139 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito);
143 } 140 }
144 141
145 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/dom_storage/dom_storage_context_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698