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

Unified Diff: net/base/mock_file_stream.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/mock_file_stream.h ('k') | net/base/net_error_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mock_file_stream.cc
diff --git a/net/base/mock_file_stream.cc b/net/base/mock_file_stream.cc
deleted file mode 100644
index a34edb218be9ed54cb8140aa4aa5db9ed9152507..0000000000000000000000000000000000000000
--- a/net/base/mock_file_stream.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/mock_file_stream.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-
-namespace net {
-
-namespace testing {
-
-MockFileStream::MockFileStream(
- const scoped_refptr<base::TaskRunner>& task_runner)
- : net::FileStream(task_runner),
- forced_error_(net::OK),
- async_error_(false),
- throttled_(false),
- weak_factory_(this) {
-}
-
-MockFileStream::MockFileStream(
- base::File file,
- const scoped_refptr<base::TaskRunner>& task_runner)
- : net::FileStream(file.Pass(), task_runner),
- forced_error_(net::OK),
- async_error_(false),
- throttled_(false),
- weak_factory_(this) {
-}
-
-MockFileStream::~MockFileStream() {
-}
-
-int MockFileStream::Seek(base::File::Whence whence, int64 offset,
- const Int64CompletionCallback& callback) {
- Int64CompletionCallback wrapped_callback =
- base::Bind(&MockFileStream::DoCallback64,
- weak_factory_.GetWeakPtr(), callback);
- if (forced_error_ == net::OK)
- return FileStream::Seek(whence, offset, wrapped_callback);
- return ErrorCallback64(wrapped_callback);
-}
-
-int MockFileStream::Read(IOBuffer* buf,
- int buf_len,
- const CompletionCallback& callback) {
- CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback,
- weak_factory_.GetWeakPtr(),
- callback);
- if (forced_error_ == net::OK)
- return FileStream::Read(buf, buf_len, wrapped_callback);
- return ErrorCallback(wrapped_callback);
-}
-
-int MockFileStream::Write(IOBuffer* buf,
- int buf_len,
- const CompletionCallback& callback) {
- CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback,
- weak_factory_.GetWeakPtr(),
- callback);
- if (forced_error_ == net::OK)
- return FileStream::Write(buf, buf_len, wrapped_callback);
- return ErrorCallback(wrapped_callback);
-}
-
-int MockFileStream::Flush(const CompletionCallback& callback) {
- CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback,
- weak_factory_.GetWeakPtr(),
- callback);
- if (forced_error_ == net::OK)
- return FileStream::Flush(wrapped_callback);
- return ErrorCallback(wrapped_callback);
-}
-
-void MockFileStream::ThrottleCallbacks() {
- CHECK(!throttled_);
- throttled_ = true;
-}
-
-void MockFileStream::ReleaseCallbacks() {
- CHECK(throttled_);
- throttled_ = false;
-
- if (!throttled_task_.is_null()) {
- base::Closure throttled_task = throttled_task_;
- throttled_task_.Reset();
- base::MessageLoop::current()->PostTask(FROM_HERE, throttled_task);
- }
-}
-
-void MockFileStream::DoCallback(const CompletionCallback& callback,
- int result) {
- if (!throttled_) {
- callback.Run(result);
- return;
- }
- CHECK(throttled_task_.is_null());
- throttled_task_ = base::Bind(callback, result);
-}
-
-void MockFileStream::DoCallback64(const Int64CompletionCallback& callback,
- int64 result) {
- if (!throttled_) {
- callback.Run(result);
- return;
- }
- CHECK(throttled_task_.is_null());
- throttled_task_ = base::Bind(callback, result);
-}
-
-int MockFileStream::ErrorCallback(const CompletionCallback& callback) {
- CHECK_NE(net::OK, forced_error_);
- if (async_error_) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(callback, forced_error_));
- clear_forced_error();
- return net::ERR_IO_PENDING;
- }
- int ret = forced_error_;
- clear_forced_error();
- return ret;
-}
-
-int64 MockFileStream::ErrorCallback64(const Int64CompletionCallback& callback) {
- CHECK_NE(net::OK, forced_error_);
- if (async_error_) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(callback, forced_error_));
- clear_forced_error();
- return net::ERR_IO_PENDING;
- }
- int64 ret = forced_error_;
- clear_forced_error();
- return ret;
-}
-
-} // namespace testing
-
-} // namespace net
« no previous file with comments | « net/base/mock_file_stream.h ('k') | net/base/net_error_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698