Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: webkit/fileapi/file_system_operation_unittest.cc

Issue 10066044: RefCounted types should not have public destructors, webkit/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation ordering Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/fileapi/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 accessed_(0) {} 55 accessed_(0) {}
56 56
57 virtual void GetUsageAndQuota( 57 virtual void GetUsageAndQuota(
58 const GURL& origin, quota::StorageType type, 58 const GURL& origin, quota::StorageType type,
59 const GetUsageAndQuotaCallback& callback) OVERRIDE { 59 const GetUsageAndQuotaCallback& callback) OVERRIDE {
60 EXPECT_EQ(origin_, origin); 60 EXPECT_EQ(origin_, origin);
61 EXPECT_EQ(type_, type); 61 EXPECT_EQ(type_, type);
62 callback.Run(quota::kQuotaStatusOk, usage_, quota_); 62 callback.Run(quota::kQuotaStatusOk, usage_, quota_);
63 } 63 }
64 64
65 protected:
66 virtual ~MockQuotaManager() {}
67
65 private: 68 private:
66 friend class MockQuotaManagerProxy; 69 friend class MockQuotaManagerProxy;
70
67 void SetQuota(const GURL& origin, StorageType type, int64 quota) { 71 void SetQuota(const GURL& origin, StorageType type, int64 quota) {
68 EXPECT_EQ(origin_, origin); 72 EXPECT_EQ(origin_, origin);
69 EXPECT_EQ(type_, type); 73 EXPECT_EQ(type_, type);
70 quota_ = quota; 74 quota_ = quota;
71 } 75 }
72 76
73 void RecordStorageAccessed(const GURL& origin, StorageType type) { 77 void RecordStorageAccessed(const GURL& origin, StorageType type) {
74 EXPECT_EQ(origin_, origin); 78 EXPECT_EQ(origin_, origin);
75 EXPECT_EQ(type_, type); 79 EXPECT_EQ(type_, type);
76 ++accessed_; 80 ++accessed_;
(...skipping 13 matching lines...) Expand all
90 }; 94 };
91 95
92 class MockQuotaManagerProxy : public QuotaManagerProxy { 96 class MockQuotaManagerProxy : public QuotaManagerProxy {
93 public: 97 public:
94 explicit MockQuotaManagerProxy(QuotaManager* quota_manager) 98 explicit MockQuotaManagerProxy(QuotaManager* quota_manager)
95 : QuotaManagerProxy(quota_manager, 99 : QuotaManagerProxy(quota_manager,
96 base::MessageLoopProxy::current()), 100 base::MessageLoopProxy::current()),
97 registered_client_(NULL) { 101 registered_client_(NULL) {
98 } 102 }
99 103
100 virtual ~MockQuotaManagerProxy() {
101 EXPECT_FALSE(registered_client_);
102 }
103
104 virtual void RegisterClient(QuotaClient* client) OVERRIDE { 104 virtual void RegisterClient(QuotaClient* client) OVERRIDE {
105 EXPECT_FALSE(registered_client_); 105 EXPECT_FALSE(registered_client_);
106 registered_client_ = client; 106 registered_client_ = client;
107 } 107 }
108 108
109 void SimulateQuotaManagerDestroyed() { 109 void SimulateQuotaManagerDestroyed() {
110 if (registered_client_) { 110 if (registered_client_) {
111 // We cannot call this in the destructor as the client (indirectly) 111 // We cannot call this in the destructor as the client (indirectly)
112 // holds a refptr of the proxy. 112 // holds a refptr of the proxy.
113 registered_client_->OnQuotaManagerDestroyed(); 113 registered_client_->OnQuotaManagerDestroyed();
(...skipping 19 matching lines...) Expand all
133 } 133 }
134 134
135 int storage_accessed_count() const { 135 int storage_accessed_count() const {
136 return mock_manager()->accessed_; 136 return mock_manager()->accessed_;
137 } 137 }
138 138
139 void SetQuota(const GURL& origin, StorageType type, int64 quota) { 139 void SetQuota(const GURL& origin, StorageType type, int64 quota) {
140 mock_manager()->SetQuota(origin, type, quota); 140 mock_manager()->SetQuota(origin, type, quota);
141 } 141 }
142 142
143 protected:
144 virtual ~MockQuotaManagerProxy() {
145 EXPECT_FALSE(registered_client_);
146 }
147
143 private: 148 private:
144 MockQuotaManager* mock_manager() const { 149 MockQuotaManager* mock_manager() const {
145 return static_cast<MockQuotaManager*>(quota_manager()); 150 return static_cast<MockQuotaManager*>(quota_manager());
146 } 151 }
152
147 QuotaClient* registered_client_; 153 QuotaClient* registered_client_;
148 }; 154 };
149 155
150 FilePath ASCIIToFilePath(const std::string& str) { 156 FilePath ASCIIToFilePath(const std::string& str) {
151 return FilePath().AppendASCII(str); 157 return FilePath().AppendASCII(str);
152 } 158 }
153 159
154 } // namespace (anonymous) 160 } // namespace (anonymous)
155 161
156 // Test class for FileSystemOperation. 162 // Test class for FileSystemOperation.
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 1141 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
1136 EXPECT_FALSE(info().is_directory); 1142 EXPECT_FALSE(info().is_directory);
1137 EXPECT_EQ(PlatformPath(file_path), path()); 1143 EXPECT_EQ(PlatformPath(file_path), path());
1138 1144
1139 // The FileSystemOpration implementation does not create a 1145 // The FileSystemOpration implementation does not create a
1140 // shareable file reference. 1146 // shareable file reference.
1141 EXPECT_EQ(NULL, shareable_file_ref()); 1147 EXPECT_EQ(NULL, shareable_file_ref());
1142 } 1148 }
1143 1149
1144 } // namespace fileapi 1150 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.cc ('k') | webkit/fileapi/file_system_operation_write_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698