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

Side by Side Diff: content/public/test/async_file_test_helper.cc

Issue 181063031: Fix AsyncFileTestHelper::ReadDirectory to handle has_more correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/public/test/async_file_test_helper.h" 9 #include "content/public/test/async_file_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/browser/fileapi/file_system_backend.h" 11 #include "webkit/browser/fileapi/file_system_backend.h"
12 #include "webkit/browser/fileapi/file_system_context.h" 12 #include "webkit/browser/fileapi/file_system_context.h"
13 #include "webkit/browser/fileapi/file_system_operation_runner.h" 13 #include "webkit/browser/fileapi/file_system_operation_runner.h"
14 #include "webkit/browser/fileapi/file_system_url.h" 14 #include "webkit/browser/fileapi/file_system_url.h"
15 #include "webkit/browser/quota/quota_manager.h" 15 #include "webkit/browser/quota/quota_manager.h"
16 #include "webkit/common/fileapi/file_system_util.h" 16 #include "webkit/common/fileapi/file_system_util.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 typedef fileapi::FileSystemOperation::FileEntryList FileEntryList; 20 typedef fileapi::FileSystemOperation::FileEntryList FileEntryList;
21 21
22 namespace {
23
22 void AssignAndQuit(base::RunLoop* run_loop, 24 void AssignAndQuit(base::RunLoop* run_loop,
23 base::File::Error* result_out, 25 base::File::Error* result_out,
24 base::File::Error result) { 26 base::File::Error result) {
25 *result_out = result; 27 *result_out = result;
26 run_loop->Quit(); 28 run_loop->Quit();
27 } 29 }
28 30
29 base::Callback<void(base::File::Error)> 31 base::Callback<void(base::File::Error)>
30 AssignAndQuitCallback(base::RunLoop* run_loop, 32 AssignAndQuitCallback(base::RunLoop* run_loop,
31 base::File::Error* result) { 33 base::File::Error* result) {
(...skipping 26 matching lines...) Expand all
58 run_loop->Quit(); 60 run_loop->Quit();
59 } 61 }
60 62
61 void ReadDirectoryCallback(base::RunLoop* run_loop, 63 void ReadDirectoryCallback(base::RunLoop* run_loop,
62 base::File::Error* result_out, 64 base::File::Error* result_out,
63 FileEntryList* entries_out, 65 FileEntryList* entries_out,
64 base::File::Error result, 66 base::File::Error result,
65 const FileEntryList& entries, 67 const FileEntryList& entries,
66 bool has_more) { 68 bool has_more) {
67 *result_out = result; 69 *result_out = result;
68 *entries_out = entries; 70 entries_out->insert(entries_out->end(), entries.begin(), entries.end());
69 if (result != base::File::FILE_OK || !has_more) 71 if (result != base::File::FILE_OK || !has_more)
70 run_loop->Quit(); 72 run_loop->Quit();
71 } 73 }
72 74
73 void DidGetUsageAndQuota(quota::QuotaStatusCode* status_out, 75 void DidGetUsageAndQuota(quota::QuotaStatusCode* status_out,
74 int64* usage_out, 76 int64* usage_out,
75 int64* quota_out, 77 int64* quota_out,
76 quota::QuotaStatusCode status, 78 quota::QuotaStatusCode status,
77 int64 usage, 79 int64 usage,
78 int64 quota) { 80 int64 quota) {
79 if (status_out) 81 if (status_out)
80 *status_out = status; 82 *status_out = status;
81 if (usage_out) 83 if (usage_out)
82 *usage_out = usage; 84 *usage_out = usage;
83 if (quota_out) 85 if (quota_out)
84 *quota_out = quota; 86 *quota_out = quota;
85 } 87 }
86 88
89 } // namespace
90
87 const int64 AsyncFileTestHelper::kDontCheckSize = -1; 91 const int64 AsyncFileTestHelper::kDontCheckSize = -1;
88 92
89 base::File::Error AsyncFileTestHelper::Copy( 93 base::File::Error AsyncFileTestHelper::Copy(
90 fileapi::FileSystemContext* context, 94 fileapi::FileSystemContext* context,
91 const fileapi::FileSystemURL& src, 95 const fileapi::FileSystemURL& src,
92 const fileapi::FileSystemURL& dest) { 96 const fileapi::FileSystemURL& dest) {
93 return CopyWithProgress(context, src, dest, CopyProgressCallback()); 97 return CopyWithProgress(context, src, dest, CopyProgressCallback());
94 } 98 }
95 99
96 base::File::Error AsyncFileTestHelper::CopyWithProgress( 100 base::File::Error AsyncFileTestHelper::CopyWithProgress(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 quota::QuotaStatusCode status = quota::kQuotaStatusUnknown; 261 quota::QuotaStatusCode status = quota::kQuotaStatusUnknown;
258 quota_manager->GetUsageAndQuota( 262 quota_manager->GetUsageAndQuota(
259 origin, 263 origin,
260 FileSystemTypeToQuotaStorageType(type), 264 FileSystemTypeToQuotaStorageType(type),
261 base::Bind(&DidGetUsageAndQuota, &status, usage, quota)); 265 base::Bind(&DidGetUsageAndQuota, &status, usage, quota));
262 base::RunLoop().RunUntilIdle(); 266 base::RunLoop().RunUntilIdle();
263 return status; 267 return status;
264 } 268 }
265 269
266 } // namespace fileapi 270 } // namespace fileapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698