OLD | NEW |
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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/scoped_callback_factory.h" | 7 #include "base/memory/scoped_callback_factory.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 const char kDummyURL2[] = "http://www.example.com"; | 28 const char kDummyURL2[] = "http://www.example.com"; |
29 const char kDummyURL3[] = "http://www.bleh"; | 29 const char kDummyURL3[] = "http://www.bleh"; |
30 | 30 |
31 // Declared to shorten the variable names. | 31 // Declared to shorten the variable names. |
32 const quota::StorageType kTemporary = quota::kStorageTypeTemporary; | 32 const quota::StorageType kTemporary = quota::kStorageTypeTemporary; |
33 const quota::StorageType kPersistent = quota::kStorageTypePersistent; | 33 const quota::StorageType kPersistent = quota::kStorageTypePersistent; |
34 | 34 |
35 class MockFileSystemPathManager : public FileSystemPathManager { | 35 class MockFileSystemPathManager : public FileSystemPathManager { |
36 public: | 36 public: |
37 explicit MockFileSystemPathManager(const FilePath& filesystem_path) | 37 explicit MockFileSystemPathManager(const FilePath& filesystem_path) |
38 : FileSystemPathManager(base::MessageLoopProxy::CreateForCurrentThread(), | 38 : FileSystemPathManager(base::MessageLoopProxy::current(), |
39 filesystem_path, NULL, false, true) {} | 39 filesystem_path, NULL, false, true) {} |
40 }; | 40 }; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 class FileSystemQuotaClientTest : public testing::Test { | 44 class FileSystemQuotaClientTest : public testing::Test { |
45 public: | 45 public: |
46 FileSystemQuotaClientTest() | 46 FileSystemQuotaClientTest() |
47 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 47 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
48 additional_callback_count_(0), | 48 additional_callback_count_(0), |
49 deletion_status_(quota::kQuotaStatusUnknown) { | 49 deletion_status_(quota::kQuotaStatusUnknown) { |
50 } | 50 } |
51 | 51 |
52 void SetUp() { | 52 void SetUp() { |
53 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 53 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
54 file_system_context_ = | 54 file_system_context_ = |
55 new FileSystemContext( | 55 new FileSystemContext( |
56 base::MessageLoopProxy::CreateForCurrentThread(), | 56 base::MessageLoopProxy::current(), |
57 base::MessageLoopProxy::CreateForCurrentThread(), | 57 base::MessageLoopProxy::current(), |
58 NULL, NULL, | 58 NULL, NULL, |
59 FilePath(), false /* is_incognito */, | 59 FilePath(), false /* is_incognito */, |
60 false, true, | 60 false, true, |
61 new MockFileSystemPathManager(data_dir_.path())); | 61 new MockFileSystemPathManager(data_dir_.path())); |
62 } | 62 } |
63 | 63 |
64 struct TestFile { | 64 struct TestFile { |
65 bool isDirectory; | 65 bool isDirectory; |
66 const char* name; | 66 const char* name; |
67 int64 size; | 67 int64 size; |
68 const char* origin_url; | 68 const char* origin_url; |
69 quota::StorageType type; | 69 quota::StorageType type; |
70 }; | 70 }; |
71 | 71 |
72 protected: | 72 protected: |
73 FileSystemQuotaClient* NewQuotaClient(bool is_incognito) { | 73 FileSystemQuotaClient* NewQuotaClient(bool is_incognito) { |
74 return new FileSystemQuotaClient( | 74 return new FileSystemQuotaClient( |
75 base::MessageLoopProxy::CreateForCurrentThread(), | 75 base::MessageLoopProxy::current(), |
76 file_system_context_, is_incognito); | 76 file_system_context_, is_incognito); |
77 } | 77 } |
78 | 78 |
79 void GetOriginUsageAsync(FileSystemQuotaClient* quota_client, | 79 void GetOriginUsageAsync(FileSystemQuotaClient* quota_client, |
80 const std::string& origin_url, | 80 const std::string& origin_url, |
81 quota::StorageType type) { | 81 quota::StorageType type) { |
82 quota_client->GetOriginUsage(GURL(origin_url), type, | 82 quota_client->GetOriginUsage(GURL(origin_url), type, |
83 callback_factory_.NewCallback( | 83 callback_factory_.NewCallback( |
84 &FileSystemQuotaClientTest::OnGetUsage)); | 84 &FileSystemQuotaClientTest::OnGetUsage)); |
85 } | 85 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 GetOriginUsage(quota_client.get(), | 591 GetOriginUsage(quota_client.get(), |
592 "https://bar.com/", | 592 "https://bar.com/", |
593 kPersistent)); | 593 kPersistent)); |
594 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, | 594 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, |
595 GetOriginUsage(quota_client.get(), | 595 GetOriginUsage(quota_client.get(), |
596 "https://bar.com/", | 596 "https://bar.com/", |
597 kTemporary)); | 597 kTemporary)); |
598 } | 598 } |
599 | 599 |
600 } // namespace fileapi | 600 } // namespace fileapi |
OLD | NEW |