15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef NET_FAILING_HTTP_TRANSACTION_FACTORY_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define NET_FAILING_HTTP_TRANSACTION_FACTORY_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/base/net_errors.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/base/request_priority.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/http/http_transaction.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "net/http/http_transaction_factory.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace net { 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class HttpCache; 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class HttpNetworkSession; 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Creates transactions that always (asynchronously) return a specified 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// error. The error is returned asynchronously, just after the transaction is 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// started. 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class NET_EXPORT FailingHttpTransactionFactory : public HttpTransactionFactory { 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The caller must guarantee that |session| outlives this object. 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FailingHttpTransactionFactory(HttpNetworkSession* session, Error error); 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~FailingHttpTransactionFactory(); 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // HttpTransactionFactory: 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual int CreateTransaction( 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RequestPriority priority, 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<HttpTransaction>* trans) OVERRIDE; 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual HttpCache* GetCache() OVERRIDE; 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual HttpNetworkSession* GetSession() OVERRIDE; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) HttpNetworkSession* session_; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Error error_; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace net 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // NET_FAILING_HTTP_TRANSACTION_FACTORY_H_ 43