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

Side by Side Diff: content/child/fileapi/webfilewriter_base_unittest.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/child/fileapi/webfilewriter_base.h" 5 #include "content/child/fileapi/webfilewriter_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 protected: 67 protected:
68 virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE { 68 virtual void DoTruncate(const GURL& path, int64 offset) OVERRIDE {
69 received_truncate_ = true; 69 received_truncate_ = true;
70 received_truncate_path_ = path; 70 received_truncate_path_ = path;
71 received_truncate_offset_ = offset; 71 received_truncate_offset_ = offset;
72 72
73 if (offset == kBasicFileTruncate_Offset) { 73 if (offset == kBasicFileTruncate_Offset) {
74 DidSucceed(); 74 DidSucceed();
75 } else if (offset == kErrorFileTruncate_Offset) { 75 } else if (offset == kErrorFileTruncate_Offset) {
76 DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); 76 DidFail(base::File::FILE_ERROR_NOT_FOUND);
77 } else if (offset == kCancelFileTruncate_Offset) { 77 } else if (offset == kCancelFileTruncate_Offset) {
78 cancel(); 78 cancel();
79 DidSucceed(); // truncate completion 79 DidSucceed(); // truncate completion
80 DidSucceed(); // cancel completion 80 DidSucceed(); // cancel completion
81 } else if (offset == kCancelFailedTruncate_Offset) { 81 } else if (offset == kCancelFailedTruncate_Offset) {
82 cancel(); 82 cancel();
83 DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); // truncate completion 83 DidFail(base::File::FILE_ERROR_NOT_FOUND); // truncate completion
84 DidSucceed(); // cancel completion 84 DidSucceed(); // cancel completion
85 } else { 85 } else {
86 FAIL(); 86 FAIL();
87 } 87 }
88 } 88 }
89 89
90 virtual void DoWrite( 90 virtual void DoWrite(
91 const GURL& path, const std::string& blob_uuid, 91 const GURL& path, const std::string& blob_uuid,
92 int64 offset) OVERRIDE { 92 int64 offset) OVERRIDE {
93 received_write_ = true; 93 received_write_ = true;
94 received_write_path_ = path; 94 received_write_path_ = path;
95 received_write_offset_ = offset; 95 received_write_offset_ = offset;
96 received_write_blob_uuid_ = blob_uuid; 96 received_write_blob_uuid_ = blob_uuid;
97 97
98 if (offset == kBasicFileWrite_Offset) { 98 if (offset == kBasicFileWrite_Offset) {
99 DidWrite(1, true); 99 DidWrite(1, true);
100 } else if (offset == kErrorFileWrite_Offset) { 100 } else if (offset == kErrorFileWrite_Offset) {
101 DidFail(base::PLATFORM_FILE_ERROR_NOT_FOUND); 101 DidFail(base::File::FILE_ERROR_NOT_FOUND);
102 } else if (offset == kMultiFileWrite_Offset) { 102 } else if (offset == kMultiFileWrite_Offset) {
103 DidWrite(1, false); 103 DidWrite(1, false);
104 DidWrite(1, false); 104 DidWrite(1, false);
105 DidWrite(1, true); 105 DidWrite(1, true);
106 } else if (offset == kCancelFileWriteBeforeCompletion_Offset) { 106 } else if (offset == kCancelFileWriteBeforeCompletion_Offset) {
107 DidWrite(1, false); 107 DidWrite(1, false);
108 cancel(); 108 cancel();
109 DidWrite(1, false); 109 DidWrite(1, false);
110 DidWrite(1, false); 110 DidWrite(1, false);
111 DidFail(base::PLATFORM_FILE_ERROR_FAILED); // write completion 111 DidFail(base::File::FILE_ERROR_FAILED); // write completion
112 DidSucceed(); // cancel completion 112 DidSucceed(); // cancel completion
113 } else if (offset == kCancelFileWriteAfterCompletion_Offset) { 113 } else if (offset == kCancelFileWriteAfterCompletion_Offset) {
114 DidWrite(1, false); 114 DidWrite(1, false);
115 cancel(); 115 cancel();
116 DidWrite(1, false); 116 DidWrite(1, false);
117 DidWrite(1, false); 117 DidWrite(1, false);
118 DidWrite(1, true); // write completion 118 DidWrite(1, true); // write completion
119 DidFail(base::PLATFORM_FILE_ERROR_FAILED); // cancel completion 119 DidFail(base::File::FILE_ERROR_FAILED); // cancel completion
120 } else { 120 } else {
121 FAIL(); 121 FAIL();
122 } 122 }
123 } 123 }
124 124
125 virtual void DoCancel() OVERRIDE { 125 virtual void DoCancel() OVERRIDE {
126 received_cancel_ = true; 126 received_cancel_ = true;
127 } 127 }
128 }; 128 };
129 129
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 reset(); 412 reset();
413 delete_in_client_callback_ = true; 413 delete_in_client_callback_ = true;
414 writer()->truncate(kErrorFileTruncate_Offset); 414 writer()->truncate(kErrorFileTruncate_Offset);
415 EXPECT_FALSE(testable_writer_.get()); 415 EXPECT_FALSE(testable_writer_.get());
416 416
417 // Not crashing counts as passing. 417 // Not crashing counts as passing.
418 } 418 }
419 419
420 } // namespace content 420 } // namespace content
OLDNEW
« no previous file with comments | « content/child/fileapi/webfilewriter_base.cc ('k') | content/child/fileapi/webfilewriter_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698