Introduce ProfilerMetricsProvider
[chromium-blink-merge.git] / chrome / browser / devtools / devtools_network_transaction.h
blob5a51ab200e47d45da675d2337049d4aec7b11e1f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "net/base/completion_callback.h"
10 #include "net/base/load_states.h"
11 #include "net/base/request_priority.h"
12 #include "net/http/http_transaction.h"
13 #include "net/websockets/websocket_handshake_stream_base.h"
15 class DevToolsNetworkController;
16 class GURL;
18 namespace net {
19 class AuthCredentials;
20 class BoundNetLog;
21 class HttpRequestHeaders;
22 struct HttpRequestInfo;
23 class HttpResponseInfo;
24 class HttpNetworkSession;
25 class IOBuffer;
26 struct LoadTimingInfo;
27 class UploadProgress;
28 class X509Certificate;
31 // DevToolsNetworkTransaction is a wrapper for network transaction. All
32 // HttpTransaction methods are proxied to real transaction, but |callback|
33 // parameter is saved and replaced with proxy callback. Fail method should be
34 // used to simulate network outage. It runs saved callback (if any) with
35 // net::ERR_INTERNET_DISCONNECTED result value.
36 class DevToolsNetworkTransaction : public net::HttpTransaction {
37 public:
38 DevToolsNetworkTransaction(
39 DevToolsNetworkController* controller,
40 scoped_ptr<net::HttpTransaction> network_transaction);
42 virtual ~DevToolsNetworkTransaction();
44 const net::HttpRequestInfo* request() const { return request_; }
45 bool failed() const { return failed_; }
47 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value.
48 void Fail();
50 // HttpTransaction methods:
51 virtual int Start(
52 const net::HttpRequestInfo* request,
53 const net::CompletionCallback& callback,
54 const net::BoundNetLog& net_log) OVERRIDE;
55 virtual int RestartIgnoringLastError(
56 const net::CompletionCallback& callback) OVERRIDE;
57 virtual int RestartWithCertificate(
58 net::X509Certificate* client_cert,
59 const net::CompletionCallback& callback) OVERRIDE;
60 virtual int RestartWithAuth(
61 const net::AuthCredentials& credentials,
62 const net::CompletionCallback& callback) OVERRIDE;
63 virtual bool IsReadyToRestartForAuth() OVERRIDE;
65 virtual int Read(
66 net::IOBuffer* buf,
67 int buf_len,
68 const net::CompletionCallback& callback) OVERRIDE;
69 virtual void StopCaching() OVERRIDE;
70 virtual bool GetFullRequestHeaders(
71 net::HttpRequestHeaders* headers) const OVERRIDE;
72 virtual int64 GetTotalReceivedBytes() const OVERRIDE;
73 virtual void DoneReading() OVERRIDE;
74 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE;
75 virtual net::LoadState GetLoadState() const OVERRIDE;
76 virtual net::UploadProgress GetUploadProgress() const OVERRIDE;
77 virtual void SetQuicServerInfo(
78 net::QuicServerInfo* quic_server_info) OVERRIDE;
79 virtual bool GetLoadTimingInfo(
80 net::LoadTimingInfo* load_timing_info) const OVERRIDE;
81 virtual void SetPriority(net::RequestPriority priority) OVERRIDE;
82 virtual void SetWebSocketHandshakeStreamCreateHelper(
83 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE;
84 virtual void SetBeforeNetworkStartCallback(
85 const BeforeNetworkStartCallback& callback) OVERRIDE;
86 virtual int ResumeNetworkStart() OVERRIDE;
88 private:
89 // Proxy callback handler. Runs saved callback.
90 void OnCallback(int result);
92 DevToolsNetworkController* controller_;
94 // Real network transaction.
95 scoped_ptr<net::HttpTransaction> network_transaction_;
97 const net::HttpRequestInfo* request_;
99 // True if Start was already invoked.
100 bool started_;
102 // True if Fail was already invoked.
103 bool failed_;
105 net::CompletionCallback proxy_callback_;
106 net::CompletionCallback callback_;
108 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction);
111 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_