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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 2930183002: Let IndexedDBContextImpl create its own task runner (Closed)
Patch Set: rebased Created 3 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 4604 matching lines...) Expand 10 before | Expand all | Expand 10 after
4615 // stores data in the host file system. 4615 // stores data in the host file system.
4616 base::FilePath lso_dir_path = 4616 base::FilePath lso_dir_path =
4617 profile()->GetPath().AppendASCII("Local Storage"); 4617 profile()->GetPath().AppendASCII("Local Storage");
4618 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4618 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
4619 .AddExtension(FILE_PATH_LITERAL(".localstorage")); 4619 .AddExtension(FILE_PATH_LITERAL(".localstorage"));
4620 EXPECT_TRUE(base::CreateDirectory(lso_dir_path)); 4620 EXPECT_TRUE(base::CreateDirectory(lso_dir_path));
4621 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0)); 4621 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0));
4622 EXPECT_TRUE(base::PathExists(lso_file_path)); 4622 EXPECT_TRUE(base::PathExists(lso_file_path));
4623 4623
4624 // Create indexed db. Similarly, it is enough to only simulate this by 4624 // Create indexed db. Similarly, it is enough to only simulate this by
4625 // creating the directory on the disk. 4625 // creating the directory on the disk, and resetting the caches of
4626 // "known" origins.
4626 IndexedDBContext* idb_context = BrowserContext::GetDefaultStoragePartition( 4627 IndexedDBContext* idb_context = BrowserContext::GetDefaultStoragePartition(
4627 profile())->GetIndexedDBContext(); 4628 profile())->GetIndexedDBContext();
4628 idb_context->SetTaskRunnerForTesting(
4629 base::ThreadTaskRunnerHandle::Get().get());
4630 base::FilePath idb_path = idb_context->GetFilePathForTesting(ext_url); 4629 base::FilePath idb_path = idb_context->GetFilePathForTesting(ext_url);
4631 EXPECT_TRUE(base::CreateDirectory(idb_path)); 4630 EXPECT_TRUE(base::CreateDirectory(idb_path));
4632 EXPECT_TRUE(base::DirectoryExists(idb_path)); 4631 EXPECT_TRUE(base::DirectoryExists(idb_path));
4632 idb_context->ResetCachesForTesting();
4633 4633
4634 // Uninstall the extension. 4634 // Uninstall the extension.
4635 base::RunLoop run_loop; 4635 base::RunLoop run_loop;
4636 ASSERT_TRUE( 4636 ASSERT_TRUE(
4637 service()->UninstallExtension(good_crx, 4637 service()->UninstallExtension(good_crx,
4638 extensions::UNINSTALL_REASON_FOR_TESTING, 4638 extensions::UNINSTALL_REASON_FOR_TESTING,
4639 run_loop.QuitClosure(), 4639 run_loop.QuitClosure(),
4640 NULL)); 4640 NULL));
4641 // The data deletion happens on the IO thread. 4641 // The data deletion happens on the IO thread.
4642 run_loop.Run(); 4642 run_loop.Run();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 // stores data in the host file system. 4736 // stores data in the host file system.
4737 base::FilePath lso_dir_path = 4737 base::FilePath lso_dir_path =
4738 profile()->GetPath().AppendASCII("Local Storage"); 4738 profile()->GetPath().AppendASCII("Local Storage");
4739 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4739 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
4740 .AddExtension(FILE_PATH_LITERAL(".localstorage")); 4740 .AddExtension(FILE_PATH_LITERAL(".localstorage"));
4741 EXPECT_TRUE(base::CreateDirectory(lso_dir_path)); 4741 EXPECT_TRUE(base::CreateDirectory(lso_dir_path));
4742 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0)); 4742 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0));
4743 EXPECT_TRUE(base::PathExists(lso_file_path)); 4743 EXPECT_TRUE(base::PathExists(lso_file_path));
4744 4744
4745 // Create indexed db. Similarly, it is enough to only simulate this by 4745 // Create indexed db. Similarly, it is enough to only simulate this by
4746 // creating the directory on the disk. 4746 // creating the directory on the disk, and resetting the caches of
4747 // "known" origins.
4747 IndexedDBContext* idb_context = BrowserContext::GetDefaultStoragePartition( 4748 IndexedDBContext* idb_context = BrowserContext::GetDefaultStoragePartition(
4748 profile())->GetIndexedDBContext(); 4749 profile())->GetIndexedDBContext();
4749 idb_context->SetTaskRunnerForTesting(
4750 base::ThreadTaskRunnerHandle::Get().get());
4751 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin1); 4750 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin1);
4752 EXPECT_TRUE(base::CreateDirectory(idb_path)); 4751 EXPECT_TRUE(base::CreateDirectory(idb_path));
4753 EXPECT_TRUE(base::DirectoryExists(idb_path)); 4752 EXPECT_TRUE(base::DirectoryExists(idb_path));
4753 idb_context->ResetCachesForTesting();
4754 4754
4755 // Uninstall one of them, unlimited storage should still be granted 4755 // Uninstall one of them, unlimited storage should still be granted
4756 // to the origin. 4756 // to the origin.
4757 UninstallExtension(id1, false); 4757 UninstallExtension(id1, false);
4758 EXPECT_EQ(1u, registry()->enabled_extensions().size()); 4758 EXPECT_EQ(1u, registry()->enabled_extensions().size());
4759 EXPECT_TRUE(profile()->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited( 4759 EXPECT_TRUE(profile()->GetExtensionSpecialStoragePolicy()->IsStorageUnlimited(
4760 origin1)); 4760 origin1));
4761 4761
4762 // Check that the cookie is still there. 4762 // Check that the cookie is still there.
4763 cookie_store->GetAllCookiesForURLAsync( 4763 cookie_store->GetAllCookiesForURLAsync(
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
6937 shared_module->manifest()->type()); 6937 shared_module->manifest()->type());
6938 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); 6938 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId));
6939 6939
6940 // Reload the extension and wait for it to complete. This previously crashed 6940 // Reload the extension and wait for it to complete. This previously crashed
6941 // (see crbug.com/676815). 6941 // (see crbug.com/676815).
6942 service()->ReloadExtension(kExtensionId); 6942 service()->ReloadExtension(kExtensionId);
6943 content::RunAllBlockingPoolTasksUntilIdle(); 6943 content::RunAllBlockingPoolTasksUntilIdle();
6944 // The shared module should be enabled. 6944 // The shared module should be enabled.
6945 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId)); 6945 EXPECT_TRUE(registry()->enabled_extensions().Contains(kExtensionId));
6946 } 6946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698