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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/browser/download/byte_stream.h" | 9 #include "content/browser/download/byte_stream.h" |
10 #include "content/browser/download/download_create_info.h" | 10 #include "content/browser/download/download_create_info.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 updated_(false), | 126 updated_(false), |
127 interrupt_count_(0), | 127 interrupt_count_(0), |
128 resume_count_(0) { | 128 resume_count_(0) { |
129 item_->AddObserver(this); | 129 item_->AddObserver(this); |
130 } | 130 } |
131 | 131 |
132 virtual ~MockObserver() { | 132 virtual ~MockObserver() { |
133 if (item_) item_->RemoveObserver(this); | 133 if (item_) item_->RemoveObserver(this); |
134 } | 134 } |
135 | 135 |
136 virtual void OnDownloadRemoved(DownloadItem* download) { | 136 virtual void OnDownloadRemoved(DownloadItem* download) OVERRIDE { |
137 DVLOG(20) << " " << __FUNCTION__ | 137 DVLOG(20) << " " << __FUNCTION__ |
138 << " download = " << download->DebugString(false); | 138 << " download = " << download->DebugString(false); |
139 removed_ = true; | 139 removed_ = true; |
140 } | 140 } |
141 | 141 |
142 virtual void OnDownloadUpdated(DownloadItem* download) { | 142 virtual void OnDownloadUpdated(DownloadItem* download) OVERRIDE { |
143 DVLOG(20) << " " << __FUNCTION__ | 143 DVLOG(20) << " " << __FUNCTION__ |
144 << " download = " << download->DebugString(false); | 144 << " download = " << download->DebugString(false); |
145 updated_ = true; | 145 updated_ = true; |
146 DownloadItem::DownloadState new_state = download->GetState(); | 146 DownloadItem::DownloadState new_state = download->GetState(); |
147 if (last_state_ == DownloadItem::IN_PROGRESS && | 147 if (last_state_ == DownloadItem::IN_PROGRESS && |
148 new_state == DownloadItem::INTERRUPTED) { | 148 new_state == DownloadItem::INTERRUPTED) { |
149 interrupt_count_++; | 149 interrupt_count_++; |
150 } | 150 } |
151 if (last_state_ == DownloadItem::INTERRUPTED && | 151 if (last_state_ == DownloadItem::INTERRUPTED && |
152 new_state == DownloadItem::IN_PROGRESS) { | 152 new_state == DownloadItem::IN_PROGRESS) { |
153 resume_count_++; | 153 resume_count_++; |
154 } | 154 } |
155 last_state_ = new_state; | 155 last_state_ = new_state; |
156 } | 156 } |
157 | 157 |
158 virtual void OnDownloadOpened(DownloadItem* download) { | 158 virtual void OnDownloadOpened(DownloadItem* download) OVERRIDE { |
159 DVLOG(20) << " " << __FUNCTION__ | 159 DVLOG(20) << " " << __FUNCTION__ |
160 << " download = " << download->DebugString(false); | 160 << " download = " << download->DebugString(false); |
161 } | 161 } |
162 | 162 |
163 virtual void OnDownloadDestroyed(DownloadItem* download) { | 163 virtual void OnDownloadDestroyed(DownloadItem* download) OVERRIDE { |
164 DVLOG(20) << " " << __FUNCTION__ | 164 DVLOG(20) << " " << __FUNCTION__ |
165 << " download = " << download->DebugString(false); | 165 << " download = " << download->DebugString(false); |
166 destroyed_ = true; | 166 destroyed_ = true; |
167 item_->RemoveObserver(this); | 167 item_->RemoveObserver(this); |
168 item_ = NULL; | 168 item_ = NULL; |
169 } | 169 } |
170 | 170 |
171 bool CheckRemoved() { | 171 bool CheckRemoved() { |
172 return removed_; | 172 return removed_; |
173 } | 173 } |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 EXPECT_CALL(*download_file, Detach()); | 1054 EXPECT_CALL(*download_file, Detach()); |
1055 RunAllPendingInMessageLoops(); | 1055 RunAllPendingInMessageLoops(); |
1056 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); | 1056 EXPECT_EQ(DownloadItem::COMPLETE, item->GetState()); |
1057 } | 1057 } |
1058 | 1058 |
1059 TEST(MockDownloadItem, Compiles) { | 1059 TEST(MockDownloadItem, Compiles) { |
1060 MockDownloadItem mock_item; | 1060 MockDownloadItem mock_item; |
1061 } | 1061 } |
1062 | 1062 |
1063 } // namespace content | 1063 } // namespace content |
OLD | NEW |