| 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/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "content/browser/byte_stream.h" | 10 #include "content/browser/byte_stream.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 : item_(item), | 114 : item_(item), |
| 115 last_state_(item->GetState()), | 115 last_state_(item->GetState()), |
| 116 removed_(false), | 116 removed_(false), |
| 117 destroyed_(false), | 117 destroyed_(false), |
| 118 updated_(false), | 118 updated_(false), |
| 119 interrupt_count_(0), | 119 interrupt_count_(0), |
| 120 resume_count_(0) { | 120 resume_count_(0) { |
| 121 item_->AddObserver(this); | 121 item_->AddObserver(this); |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual ~MockObserver() { | 124 ~MockObserver() override { |
| 125 if (item_) item_->RemoveObserver(this); | 125 if (item_) item_->RemoveObserver(this); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void OnDownloadRemoved(DownloadItem* download) override { | 128 void OnDownloadRemoved(DownloadItem* download) override { |
| 129 DVLOG(20) << " " << __FUNCTION__ | 129 DVLOG(20) << " " << __FUNCTION__ |
| 130 << " download = " << download->DebugString(false); | 130 << " download = " << download->DebugString(false); |
| 131 removed_ = true; | 131 removed_ = true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 virtual void OnDownloadUpdated(DownloadItem* download) override { | 134 void OnDownloadUpdated(DownloadItem* download) override { |
| 135 DVLOG(20) << " " << __FUNCTION__ | 135 DVLOG(20) << " " << __FUNCTION__ |
| 136 << " download = " << download->DebugString(false); | 136 << " download = " << download->DebugString(false); |
| 137 updated_ = true; | 137 updated_ = true; |
| 138 DownloadItem::DownloadState new_state = download->GetState(); | 138 DownloadItem::DownloadState new_state = download->GetState(); |
| 139 if (last_state_ == DownloadItem::IN_PROGRESS && | 139 if (last_state_ == DownloadItem::IN_PROGRESS && |
| 140 new_state == DownloadItem::INTERRUPTED) { | 140 new_state == DownloadItem::INTERRUPTED) { |
| 141 interrupt_count_++; | 141 interrupt_count_++; |
| 142 } | 142 } |
| 143 if (last_state_ == DownloadItem::INTERRUPTED && | 143 if (last_state_ == DownloadItem::INTERRUPTED && |
| 144 new_state == DownloadItem::IN_PROGRESS) { | 144 new_state == DownloadItem::IN_PROGRESS) { |
| 145 resume_count_++; | 145 resume_count_++; |
| 146 } | 146 } |
| 147 last_state_ = new_state; | 147 last_state_ = new_state; |
| 148 } | 148 } |
| 149 | 149 |
| 150 virtual void OnDownloadOpened(DownloadItem* download) override { | 150 void OnDownloadOpened(DownloadItem* download) override { |
| 151 DVLOG(20) << " " << __FUNCTION__ | 151 DVLOG(20) << " " << __FUNCTION__ |
| 152 << " download = " << download->DebugString(false); | 152 << " download = " << download->DebugString(false); |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual void OnDownloadDestroyed(DownloadItem* download) override { | 155 void OnDownloadDestroyed(DownloadItem* download) override { |
| 156 DVLOG(20) << " " << __FUNCTION__ | 156 DVLOG(20) << " " << __FUNCTION__ |
| 157 << " download = " << download->DebugString(false); | 157 << " download = " << download->DebugString(false); |
| 158 destroyed_ = true; | 158 destroyed_ = true; |
| 159 item_->RemoveObserver(this); | 159 item_->RemoveObserver(this); |
| 160 item_ = NULL; | 160 item_ = NULL; |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool CheckRemoved() { | 163 bool CheckRemoved() { |
| 164 return removed_; | 164 return removed_; |
| 165 } | 165 } |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 base::Unretained(&returned_path))); | 1293 base::Unretained(&returned_path))); |
| 1294 RunAllPendingInMessageLoops(); | 1294 RunAllPendingInMessageLoops(); |
| 1295 EXPECT_TRUE(returned_path.empty()); | 1295 EXPECT_TRUE(returned_path.empty()); |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 TEST(MockDownloadItem, Compiles) { | 1298 TEST(MockDownloadItem, Compiles) { |
| 1299 MockDownloadItem mock_item; | 1299 MockDownloadItem mock_item; |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 } // namespace content | 1302 } // namespace content |
| OLD | NEW |