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

Side by Side Diff: chrome/browser/devtools/devtools_network_transaction.h

Issue 182993003: Add the ability for DevTools to wrap network transactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename parameter Created 6 years, 8 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
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
7
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/net_export.h"
12 #include "net/base/request_priority.h"
13 #include "net/base/upload_progress.h"
14 #include "net/http/http_transaction.h"
15 #include "net/websockets/websocket_handshake_stream_base.h"
16
17 class DevToolsNetworkController;
18 class GURL;
19
20 namespace net {
21 class AuthCredentials;
22 class BoundNetLog;
23 class HttpRequestHeaders;
24 struct HttpRequestInfo;
25 class HttpResponseInfo;
26 class HttpNetworkSession;
27 class IOBuffer;
28 struct LoadTimingInfo;
29 class X509Certificate;
30 }
31
32 // DevToolsNetworkTransaction is a wrapper for network transaction. All
33 // HttpTransaction methods are proxied to real transaction, but |callback|
34 // parameter is saved and replaced with proxy callback. Fail method should be
35 // used to simulate network outage. It runs saved callback (if any) with
36 // net::ERR_INTERNET_DISCONNECTED result value.
37 class NET_EXPORT DevToolsNetworkTransaction : public net::HttpTransaction {
38 public:
39 DevToolsNetworkTransaction(
40 DevToolsNetworkController* controller,
41 scoped_ptr<net::HttpTransaction> network_transaction);
42
43 virtual ~DevToolsNetworkTransaction();
44
45 const net::HttpRequestInfo* request() const { return request_; }
46 bool failed() const { return failed_; }
47
48 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value.
49 void Fail();
50
51 // HttpTransaction methods:
52 virtual int Start(
53 const net::HttpRequestInfo* request,
54 const net::CompletionCallback& callback,
55 const net::BoundNetLog& net_log) OVERRIDE;
56 virtual int RestartIgnoringLastError(
57 const net::CompletionCallback& callback) OVERRIDE;
58 virtual int RestartWithCertificate(
59 net::X509Certificate* client_cert,
60 const net::CompletionCallback& callback) OVERRIDE;
61 virtual int RestartWithAuth(
62 const net::AuthCredentials& credentials,
63 const net::CompletionCallback& callback) OVERRIDE;
64 virtual bool IsReadyToRestartForAuth() OVERRIDE;
65
66 virtual int Read(
67 net::IOBuffer* buf,
68 int buf_len,
69 const net::CompletionCallback& callback) OVERRIDE;
70 virtual void StopCaching() OVERRIDE;
71 virtual bool GetFullRequestHeaders(
72 net::HttpRequestHeaders* headers) const OVERRIDE;
73 virtual int64 GetTotalReceivedBytes() const OVERRIDE;
74 virtual void DoneReading() OVERRIDE;
75 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE;
76 virtual net::LoadState GetLoadState() const OVERRIDE;
77 virtual net::UploadProgress GetUploadProgress() const OVERRIDE;
78 virtual void SetQuicServerInfo(
79 net::QuicServerInfo* quic_server_info) OVERRIDE;
80 virtual bool GetLoadTimingInfo(
81 net::LoadTimingInfo* load_timing_info) const OVERRIDE;
82 virtual void SetPriority(net::RequestPriority priority) OVERRIDE;
83 virtual void SetWebSocketHandshakeStreamCreateHelper(
84 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE;
85 virtual void SetBeforeNetworkStartCallback(
86 const BeforeNetworkStartCallback& callback) OVERRIDE;
87 virtual int ResumeNetworkStart() OVERRIDE;
88
89 private:
90 // Proxy callback handler. Runs saved callback.
91 void OnCallback(int result);
92
93 DevToolsNetworkController* controller_;
94
95 // Real network transaction.
96 scoped_ptr<net::HttpTransaction> network_transaction_;
97
98 const net::HttpRequestInfo* request_;
99
100 // True if Start was already invoked.
101 bool started_;
102
103 // True if Fail was already invoked.
104 bool failed_;
105
106 net::CompletionCallback proxy_callback_;
107 net::CompletionCallback callback_;
108
109 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction);
110 };
111
112 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698