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 <deque> | 5 #include <deque> |
6 #include <limits> | 6 #include <limits> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace { | 27 namespace { |
28 class QuotaMockPluginDelegate : public MockPluginDelegate { | 28 class QuotaMockPluginDelegate : public MockPluginDelegate { |
29 public: | 29 public: |
30 typedef PluginDelegate::AvailableSpaceCallback Callback; | 30 typedef PluginDelegate::AvailableSpaceCallback Callback; |
31 | 31 |
32 QuotaMockPluginDelegate() | 32 QuotaMockPluginDelegate() |
33 : available_space_(0), | 33 : available_space_(0), |
34 will_update_count_(0), | 34 will_update_count_(0), |
35 file_thread_(MessageLoopProxy::current()), | 35 file_thread_(MessageLoopProxy::current()), |
36 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 36 weak_factory_(this) { |
37 } | 37 } |
38 virtual ~QuotaMockPluginDelegate() {} | 38 virtual ~QuotaMockPluginDelegate() {} |
39 | 39 |
40 virtual scoped_refptr<MessageLoopProxy> GetFileThreadMessageLoopProxy() { | 40 virtual scoped_refptr<MessageLoopProxy> GetFileThreadMessageLoopProxy() { |
41 return file_thread_; | 41 return file_thread_; |
42 } | 42 } |
43 | 43 |
44 virtual void QueryAvailableSpace( | 44 virtual void QueryAvailableSpace( |
45 const GURL& origin, | 45 const GURL& origin, |
46 quota::StorageType type, | 46 quota::StorageType type, |
(...skipping 29 matching lines...) Expand all Loading... |
76 int will_update_count_; | 76 int will_update_count_; |
77 GURL file_path_; | 77 GURL file_path_; |
78 scoped_refptr<MessageLoopProxy> file_thread_; | 78 scoped_refptr<MessageLoopProxy> file_thread_; |
79 base::WeakPtrFactory<QuotaMockPluginDelegate> weak_factory_; | 79 base::WeakPtrFactory<QuotaMockPluginDelegate> weak_factory_; |
80 }; | 80 }; |
81 } // namespace | 81 } // namespace |
82 | 82 |
83 class QuotaFileIOTest : public PpapiUnittest { | 83 class QuotaFileIOTest : public PpapiUnittest { |
84 public: | 84 public: |
85 QuotaFileIOTest() | 85 QuotaFileIOTest() |
86 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | 86 : weak_factory_(this) {} |
87 | 87 |
88 virtual void SetUp() OVERRIDE { | 88 virtual void SetUp() OVERRIDE { |
89 PpapiUnittest::SetUp(); | 89 PpapiUnittest::SetUp(); |
90 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 90 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
91 base::FilePath path; | 91 base::FilePath path; |
92 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(dir_.path(), &path)); | 92 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(dir_.path(), &path)); |
93 int file_flags = base::PLATFORM_FILE_OPEN | | 93 int file_flags = base::PLATFORM_FILE_OPEN | |
94 base::PLATFORM_FILE_READ | | 94 base::PLATFORM_FILE_READ | |
95 base::PLATFORM_FILE_WRITE | | 95 base::PLATFORM_FILE_WRITE | |
96 base::PLATFORM_FILE_WRITE_ATTRIBUTES; | 96 base::PLATFORM_FILE_WRITE_ATTRIBUTES; |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 pop_result(); | 490 pop_result(); |
491 | 491 |
492 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); | 492 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); |
493 EXPECT_EQ(15, GetPlatformFileSize()); | 493 EXPECT_EQ(15, GetPlatformFileSize()); |
494 ReadPlatformFile(&read_buffer); | 494 ReadPlatformFile(&read_buffer); |
495 EXPECT_EQ("123355559012345", read_buffer); | 495 EXPECT_EQ("123355559012345", read_buffer); |
496 } | 496 } |
497 | 497 |
498 } // namespace ppapi | 498 } // namespace ppapi |
499 } // namespace webkit | 499 } // namespace webkit |
OLD | NEW |