OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_pipelined_connection_impl.h" | 5 #include "net/http/http_pipelined_connection_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 HttpPipelinedConnection::Feedback feedback)); | 74 HttpPipelinedConnection::Feedback feedback)); |
75 }; | 75 }; |
76 | 76 |
77 class SuddenCloseObserver : public MessageLoop::TaskObserver { | 77 class SuddenCloseObserver : public MessageLoop::TaskObserver { |
78 public: | 78 public: |
79 SuddenCloseObserver(HttpStream* stream, int close_before_task) | 79 SuddenCloseObserver(HttpStream* stream, int close_before_task) |
80 : stream_(stream), | 80 : stream_(stream), |
81 close_before_task_(close_before_task), | 81 close_before_task_(close_before_task), |
82 current_task_(0) { } | 82 current_task_(0) { } |
83 | 83 |
84 virtual void WillProcessTask(base::TimeTicks) OVERRIDE { | 84 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE { |
85 ++current_task_; | 85 ++current_task_; |
86 if (current_task_ == close_before_task_) { | 86 if (current_task_ == close_before_task_) { |
87 stream_->Close(false); | 87 stream_->Close(false); |
88 MessageLoop::current()->RemoveTaskObserver(this); | 88 MessageLoop::current()->RemoveTaskObserver(this); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 virtual void DidProcessTask(base::TimeTicks) OVERRIDE { } | 92 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {} |
93 | 93 |
94 private: | 94 private: |
95 HttpStream* stream_; | 95 HttpStream* stream_; |
96 int close_before_task_; | 96 int close_before_task_; |
97 int current_task_; | 97 int current_task_; |
98 }; | 98 }; |
99 | 99 |
100 class HttpPipelinedConnectionImplTest : public testing::Test { | 100 class HttpPipelinedConnectionImplTest : public testing::Test { |
101 public: | 101 public: |
102 HttpPipelinedConnectionImplTest() | 102 HttpPipelinedConnectionImplTest() |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 MessageLoop::current()->RunUntilIdle(); | 1597 MessageLoop::current()->RunUntilIdle(); |
1598 | 1598 |
1599 stream->Close(false); | 1599 stream->Close(false); |
1600 EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(1); | 1600 EXPECT_CALL(delegate_, OnPipelineHasCapacity(pipeline_.get())).Times(1); |
1601 stream.reset(NULL); | 1601 stream.reset(NULL); |
1602 } | 1602 } |
1603 | 1603 |
1604 } // anonymous namespace | 1604 } // anonymous namespace |
1605 | 1605 |
1606 } // namespace net | 1606 } // namespace net |
OLD | NEW |