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" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
16 #include "webkit/plugins/ppapi/mock_plugin_delegate.h" | 16 #include "content/renderer/pepper/mock_plugin_delegate.h" |
17 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" | 17 #include "content/renderer/pepper/ppapi_plugin_instance_impl.h" |
18 #include "webkit/plugins/ppapi/ppapi_unittest.h" | 18 #include "content/renderer/pepper/ppapi_unittest.h" |
19 #include "webkit/plugins/ppapi/quota_file_io.h" | 19 #include "content/renderer/pepper/quota_file_io.h" |
20 | 20 |
21 using base::MessageLoopProxy; | 21 using base::MessageLoopProxy; |
22 using base::PlatformFile; | 22 using base::PlatformFile; |
23 using base::PlatformFileError; | 23 using base::PlatformFileError; |
24 | 24 |
25 namespace webkit { | 25 namespace webkit { |
26 namespace ppapi { | 26 namespace ppapi { |
27 | 27 |
28 namespace { | 28 namespace { |
29 class QuotaMockPluginDelegate : public MockPluginDelegate { | 29 class QuotaMockPluginDelegate : public MockPluginDelegate { |
30 public: | 30 public: |
31 typedef PluginDelegate::AvailableSpaceCallback Callback; | 31 typedef PluginDelegate::AvailableSpaceCallback Callback; |
32 | 32 |
33 QuotaMockPluginDelegate() | 33 QuotaMockPluginDelegate() |
34 : available_space_(0), | 34 : available_space_(0), |
35 will_update_count_(0), | 35 will_update_count_(0), |
36 file_thread_(MessageLoopProxy::current()), | 36 file_thread_(MessageLoopProxy::current()), |
37 weak_factory_(this) { | 37 weak_factory_(this) { |
38 } | 38 } |
39 virtual ~QuotaMockPluginDelegate() {} | 39 virtual ~QuotaMockPluginDelegate() {} |
40 | 40 |
41 virtual scoped_refptr<MessageLoopProxy> GetFileThreadMessageLoopProxy() { | 41 virtual scoped_refptr<MessageLoopProxy> |
| 42 GetFileThreadMessageLoopProxy() OVERRIDE { |
42 return file_thread_; | 43 return file_thread_; |
43 } | 44 } |
44 | 45 |
45 virtual void QueryAvailableSpace( | 46 virtual void QueryAvailableSpace( |
46 const GURL& origin, | 47 const GURL& origin, |
47 quota::StorageType type, | 48 quota::StorageType type, |
48 const Callback& callback) OVERRIDE { | 49 const Callback& callback) OVERRIDE { |
49 DCHECK_EQ(false, callback.is_null()); | 50 DCHECK_EQ(false, callback.is_null()); |
50 MessageLoopProxy::current()->PostTask( | 51 MessageLoopProxy::current()->PostTask( |
51 FROM_HERE, base::Bind( | 52 FROM_HERE, base::Bind( |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 pop_result(); | 492 pop_result(); |
492 | 493 |
493 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); | 494 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); |
494 EXPECT_EQ(15, GetPlatformFileSize()); | 495 EXPECT_EQ(15, GetPlatformFileSize()); |
495 ReadPlatformFile(&read_buffer); | 496 ReadPlatformFile(&read_buffer); |
496 EXPECT_EQ("123355559012345", read_buffer); | 497 EXPECT_EQ("123355559012345", read_buffer); |
497 } | 498 } |
498 | 499 |
499 } // namespace ppapi | 500 } // namespace ppapi |
500 } // namespace webkit | 501 } // namespace webkit |
OLD | NEW |