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

Side by Side Diff: content/browser/appcache/chrome_appcache_service_unittest.cc

Issue 8820009: Appcache, local storage, indexed db, databases: skip exit-time deletion when restarting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/appcache/chrome_appcache_service.h" 10 #include "content/browser/appcache/chrome_appcache_service.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end()); 182 EXPECT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end());
183 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) == origins.end()); 183 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) == origins.end());
184 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) == 184 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) ==
185 origins.end()); 185 origins.end());
186 186
187 // Delete and let cleanup tasks run prior to returning. 187 // Delete and let cleanup tasks run prior to returning.
188 appcache_service = NULL; 188 appcache_service = NULL;
189 message_loop_.RunAllPending(); 189 message_loop_.RunAllPending();
190 } 190 }
191 191
192 TEST_F(ChromeAppCacheServiceTest, SaveSessionState) {
193 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
194 FilePath appcache_path = temp_dir_.path().Append(kTestingAppCacheDirname);
195
196 // Create a ChromeAppCacheService and insert data into it
197 scoped_refptr<ChromeAppCacheService> appcache_service =
198 CreateAppCacheService(appcache_path, true);
199 ASSERT_TRUE(file_util::PathExists(appcache_path));
200 ASSERT_TRUE(file_util::PathExists(appcache_path.AppendASCII("Index")));
201 InsertDataIntoAppCache(appcache_service);
202
203 appcache_service->set_clear_local_state_on_exit(true);
204 // Save session state. This should bypass the destruction-time deletion.
205 appcache_service->set_save_session_state(true);
206
207 // Test: delete the ChromeAppCacheService
208 appcache_service = NULL;
209 message_loop_.RunAllPending();
210
211 // Recreate the appcache (for reading the data back)
212 appcache_service = CreateAppCacheService(appcache_path, false);
213
214 // The directory is still there
215 ASSERT_TRUE(file_util::PathExists(appcache_path));
216
217 // No appcache data was deleted.
218 AppCacheTestHelper appcache_helper;
219 std::set<GURL> origins;
220 appcache_helper.GetOriginsWithCaches(appcache_service, &origins);
221 EXPECT_EQ(3UL, origins.size());
222 EXPECT_TRUE(origins.find(kProtectedManifestURL.GetOrigin()) != origins.end());
223 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end());
224 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) !=
225 origins.end());
226
227 // Delete and let cleanup tasks run prior to returning.
228 appcache_service = NULL;
229 message_loop_.RunAllPending();
230 }
231
192 } // namespace appcache 232 } // namespace appcache
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | content/browser/in_process_webkit/dom_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698