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 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace ppapi { | 22 namespace ppapi { |
23 | 23 |
24 namespace { | 24 namespace { |
25 class QuotaMockPluginDelegate : public MockPluginDelegate { | 25 class QuotaMockPluginDelegate : public MockPluginDelegate { |
26 public: | 26 public: |
27 typedef PluginDelegate::AvailableSpaceCallback Callback; | 27 typedef PluginDelegate::AvailableSpaceCallback Callback; |
28 | 28 |
29 QuotaMockPluginDelegate() | 29 QuotaMockPluginDelegate() |
30 : available_space_(0), | 30 : available_space_(0), |
31 will_update_count_(0), | 31 will_update_count_(0), |
32 file_thread_(MessageLoopProxy::CreateForCurrentThread()), | 32 file_thread_(MessageLoopProxy::current()), |
33 runnable_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 33 runnable_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
34 } | 34 } |
35 virtual ~QuotaMockPluginDelegate() {} | 35 virtual ~QuotaMockPluginDelegate() {} |
36 | 36 |
37 virtual scoped_refptr<MessageLoopProxy> GetFileThreadMessageLoopProxy() { | 37 virtual scoped_refptr<MessageLoopProxy> GetFileThreadMessageLoopProxy() { |
38 return file_thread_; | 38 return file_thread_; |
39 } | 39 } |
40 | 40 |
41 virtual void QueryAvailableSpace( | 41 virtual void QueryAvailableSpace( |
42 const GURL& origin, | 42 const GURL& origin, |
43 quota::StorageType type, | 43 quota::StorageType type, |
44 Callback* callback) OVERRIDE { | 44 Callback* callback) OVERRIDE { |
45 DCHECK(callback); | 45 DCHECK(callback); |
46 MessageLoopProxy::CreateForCurrentThread()->PostTask( | 46 MessageLoopProxy::current()->PostTask( |
47 FROM_HERE, runnable_factory_.NewRunnableMethod( | 47 FROM_HERE, runnable_factory_.NewRunnableMethod( |
48 &QuotaMockPluginDelegate::RunAvailableSpaceCallback, callback)); | 48 &QuotaMockPluginDelegate::RunAvailableSpaceCallback, callback)); |
49 } | 49 } |
50 | 50 |
51 virtual void WillUpdateFile(const GURL& file_path) OVERRIDE { | 51 virtual void WillUpdateFile(const GURL& file_path) OVERRIDE { |
52 file_path_ = file_path; | 52 file_path_ = file_path; |
53 ++will_update_count_; | 53 ++will_update_count_; |
54 } | 54 } |
55 | 55 |
56 virtual void DidUpdateFile(const GURL& file_path, int64_t delta) OVERRIDE { | 56 virtual void DidUpdateFile(const GURL& file_path, int64_t delta) OVERRIDE { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 pop_result(); | 479 pop_result(); |
480 | 480 |
481 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); | 481 EXPECT_EQ(22 - 15, quota_plugin_delegate()->available_space()); |
482 EXPECT_EQ(15, GetPlatformFileSize()); | 482 EXPECT_EQ(15, GetPlatformFileSize()); |
483 ReadPlatformFile(&read_buffer); | 483 ReadPlatformFile(&read_buffer); |
484 EXPECT_EQ("123355559012345", read_buffer); | 484 EXPECT_EQ("123355559012345", read_buffer); |
485 } | 485 } |
486 | 486 |
487 } // namespace ppapi | 487 } // namespace ppapi |
488 } // namespace webkit | 488 } // namespace webkit |
OLD | NEW |