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

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: test and nicer 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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_.get();
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, context(),
66 base::BindOnce(base::IgnoreResult(&base::TaskRunner::PostTask),
67 base::ThreadTaskRunnerHandle::Get(), FROM_HERE,
68 run_loop.QuitClosure())));
63 run_loop.Run(); 69 run_loop.Run();
64 } 70 }
65 71
66 void Flush() { 72 void Flush() {
67 // Process any tasks that are currently queued, to ensure 73 // Process any tasks that are currently queued, to ensure
68 // LevelDBWrapperImpl methods get called. 74 // LevelDBWrapperImpl methods get called.
69 base::RunLoop().RunUntilIdle(); 75 base::RunLoop().RunUntilIdle();
70 // And finally flush all the now queued up changes to leveldb. 76 // And finally flush all the now queued up changes to leveldb.
71 context()->Flush(); 77 BrowserThread::PostTask(
78 BrowserThread::IO, FROM_HERE,
79 base::BindOnce(&LocalStorageContextMojo::Flush, context()));
72 base::RunLoop().RunUntilIdle(); 80 base::RunLoop().RunUntilIdle();
michaeln 2017/05/03 21:01:29 I'm not sure what the RunUntilIdle() here accompli
Marijn Kruisselbrink 2017/05/04 23:03:46 Hmm, yeah, good point... probably all of this flus
73 } 81 }
74 }; 82 };
75 83
76 static const bool kIncognito = true; 84 static const bool kIncognito = true;
77 static const bool kNotIncognito = false; 85 static const bool kNotIncognito = false;
78 86
79 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) { 87 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) {
80 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito); 88 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
81 } 89 }
82 90
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // http://crbug.com/712872 All the mojo tests are flaky on Mac. 158 // http://crbug.com/712872 All the mojo tests are flaky on Mac.
151 #define MAYBE_DataMigrates DISABLED_DataMigrates 159 #define MAYBE_DataMigrates DISABLED_DataMigrates
152 #else 160 #else
153 #define MAYBE_DataMigrates DataMigrates 161 #define MAYBE_DataMigrates DataMigrates
154 #endif 162 #endif
155 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) { 163 IN_PROC_BROWSER_TEST_F(DOMStorageMigrationBrowserTest, MAYBE_DataMigrates) {
156 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); 164 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito);
157 } 165 }
158 166
159 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698