OLD | NEW |
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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/port.h" | 7 #include "base/port.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
(...skipping 2741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 | 2752 |
2753 EXPECT_FALSE(cache_impl_->IsAllocAllowed(0, kOneMB)); | 2753 EXPECT_FALSE(cache_impl_->IsAllocAllowed(0, kOneMB)); |
2754 } | 2754 } |
2755 | 2755 |
2756 // Tests that sharing of external files works and we are able to delete the | 2756 // Tests that sharing of external files works and we are able to delete the |
2757 // files when we need to. | 2757 // files when we need to. |
2758 TEST_F(DiskCacheBackendTest, FileSharing) { | 2758 TEST_F(DiskCacheBackendTest, FileSharing) { |
2759 InitCache(); | 2759 InitCache(); |
2760 | 2760 |
2761 disk_cache::Addr address(0x80000001); | 2761 disk_cache::Addr address(0x80000001); |
2762 | 2762 ASSERT_TRUE(cache_impl_->CreateExternalFile(&address)); |
2763 RunTaskForTest(base::Bind( | |
2764 base::IgnoreResult(&disk_cache::BackendImpl::CreateExternalFile), | |
2765 base::Unretained(cache_impl_), | |
2766 &address)); | |
2767 base::FilePath name = cache_impl_->GetFileName(address); | 2763 base::FilePath name = cache_impl_->GetFileName(address); |
2768 | 2764 |
2769 scoped_refptr<disk_cache::File> file(new disk_cache::File(false)); | 2765 scoped_refptr<disk_cache::File> file(new disk_cache::File(false)); |
2770 file->Init(name); | 2766 file->Init(name); |
2771 | 2767 |
2772 #if defined(OS_WIN) | 2768 #if defined(OS_WIN) |
2773 DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; | 2769 DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; |
2774 DWORD access = GENERIC_READ | GENERIC_WRITE; | 2770 DWORD access = GENERIC_READ | GENERIC_WRITE; |
2775 base::win::ScopedHandle file2(CreateFile( | 2771 base::win::ScopedHandle file2(CreateFile( |
2776 name.value().c_str(), access, sharing, NULL, OPEN_EXISTING, 0, NULL)); | 2772 name.value().c_str(), access, sharing, NULL, OPEN_EXISTING, 0, NULL)); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 delete cache; | 3059 delete cache; |
3064 DisableIntegrityCheck(); | 3060 DisableIntegrityCheck(); |
3065 } | 3061 } |
3066 | 3062 |
3067 TEST_F(DiskCacheBackendTest, SimpleCacheFixEnumerators) { | 3063 TEST_F(DiskCacheBackendTest, SimpleCacheFixEnumerators) { |
3068 SetSimpleCacheMode(); | 3064 SetSimpleCacheMode(); |
3069 BackendFixEnumerators(); | 3065 BackendFixEnumerators(); |
3070 } | 3066 } |
3071 | 3067 |
3072 #endif // !defined(OS_WIN) | 3068 #endif // !defined(OS_WIN) |
OLD | NEW |