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

Side by Side Diff: net/http/http_pipelined_host_forced.cc

Issue 9433015: Add a force pipelining option to load flags. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add backup buffer Created 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #include "net/http/http_pipelined_host_forced.h"
6
7 #include "base/values.h"
8 #include "net/http/http_pipelined_connection_impl.h"
9 #include "net/http/http_pipelined_stream.h"
10 #include "net/socket/buffered_write_stream_socket.h"
11 #include "net/socket/client_socket_handle.h"
12
13 using base::DictionaryValue;
14 using base::ListValue;
15 using base::Value;
16
17 namespace net {
18
19 HttpPipelinedHostForced::HttpPipelinedHostForced(
20 HttpPipelinedHost::Delegate* delegate,
21 const Key& key,
22 HttpPipelinedConnection::Factory* factory)
23 : delegate_(delegate),
24 key_(key),
25 factory_(factory) {
26 CHECK(key.force_pipelining());
27 if (!factory) {
28 factory_.reset(new HttpPipelinedConnectionImpl::Factory());
29 }
30 }
31
32 HttpPipelinedHostForced::~HttpPipelinedHostForced() {
33 CHECK(!pipeline_.get());
34 }
35
36 HttpPipelinedStream* HttpPipelinedHostForced::CreateStreamOnNewPipeline(
37 ClientSocketHandle* connection,
38 const SSLConfig& used_ssl_config,
39 const ProxyInfo& used_proxy_info,
40 const BoundNetLog& net_log,
41 bool was_npn_negotiated,
42 SSLClientSocket::NextProto protocol_negotiated) {
43 CHECK(!pipeline_.get());
44 StreamSocket* wrapped_socket = connection->release_socket();
45 BufferedWriteStreamSocket* buffered_socket = new BufferedWriteStreamSocket(
46 wrapped_socket);
47 connection->set_socket(buffered_socket);
48 pipeline_.reset(factory_->CreateNewPipeline(
49 connection, this, key_.origin(), used_ssl_config, used_proxy_info,
50 net_log, was_npn_negotiated, protocol_negotiated));
51 return pipeline_->CreateNewStream();
52 }
53
54 HttpPipelinedStream* HttpPipelinedHostForced::CreateStreamOnExistingPipeline() {
55 if (!pipeline_.get()) {
56 return NULL;
57 }
58 return pipeline_->CreateNewStream();
59 }
60
61 bool HttpPipelinedHostForced::IsExistingPipelineAvailable() const {
62 return pipeline_.get() != NULL;
63 }
64
65 const HttpPipelinedHost::Key& HttpPipelinedHostForced::GetKey() const {
66 return key_;
67 }
68
69 void HttpPipelinedHostForced::OnPipelineEmpty(
70 HttpPipelinedConnection* pipeline) {
71 CHECK_EQ(pipeline_.get(), pipeline);
72 pipeline_.reset();
73 delegate_->OnHostIdle(this);
74 // WARNING: We'll probably be deleted here.
75 }
76
77 void HttpPipelinedHostForced::OnPipelineHasCapacity(
78 HttpPipelinedConnection* pipeline) {
79 CHECK_EQ(pipeline_.get(), pipeline);
80 delegate_->OnHostHasAdditionalCapacity(this);
81 if (!pipeline->depth()) {
82 OnPipelineEmpty(pipeline);
83 // WARNING: We might be deleted here.
84 }
85 }
86
87 void HttpPipelinedHostForced::OnPipelineFeedback(
88 HttpPipelinedConnection* pipeline,
89 HttpPipelinedConnection::Feedback feedback) {
90 // We don't care. We always pipeline.
91 }
92
93 Value* HttpPipelinedHostForced::PipelineInfoToValue() const {
94 ListValue* list_value = new ListValue();
95 if (pipeline_.get()) {
96 DictionaryValue* pipeline_dict = new DictionaryValue;
97 pipeline_dict->SetString("host", key_.origin().ToString());
98 pipeline_dict->SetBoolean("forced", key_.force_pipelining());
99 pipeline_dict->SetInteger("depth", pipeline_->depth());
100 pipeline_dict->SetInteger("capacity", 1000);
101 pipeline_dict->SetBoolean("usable", pipeline_->usable());
102 pipeline_dict->SetBoolean("active", pipeline_->active());
103 pipeline_dict->SetInteger("source_id", pipeline_->net_log().source().id);
104 list_value->Append(pipeline_dict);
105 }
106 return list_value;
107 }
108
109 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698