| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 SafeBrowsingUIManager* ui_manager, | 129 SafeBrowsingUIManager* ui_manager, |
| 130 WebContents* web_contents, | 130 WebContents* web_contents, |
| 131 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource, | 131 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource, |
| 132 net::URLRequestContextGetter* request_context_getter) | 132 net::URLRequestContextGetter* request_context_getter) |
| 133 : MalwareDetails(ui_manager, web_contents, unsafe_resource) { | 133 : MalwareDetails(ui_manager, web_contents, unsafe_resource) { |
| 134 | 134 |
| 135 request_context_getter_ = request_context_getter; | 135 request_context_getter_ = request_context_getter; |
| 136 } | 136 } |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 virtual ~MalwareDetailsWrap() {} | 139 ~MalwareDetailsWrap() override {} |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { | 142 class MockSafeBrowsingUIManager : public SafeBrowsingUIManager { |
| 143 public: | 143 public: |
| 144 base::RunLoop* run_loop_; | 144 base::RunLoop* run_loop_; |
| 145 // The safe browsing UI manager does not need a service for this test. | 145 // The safe browsing UI manager does not need a service for this test. |
| 146 MockSafeBrowsingUIManager() | 146 MockSafeBrowsingUIManager() |
| 147 : SafeBrowsingUIManager(NULL), run_loop_(NULL) {} | 147 : SafeBrowsingUIManager(NULL), run_loop_(NULL) {} |
| 148 | 148 |
| 149 // When the MalwareDetails is done, this is called. | 149 // When the MalwareDetails is done, this is called. |
| 150 virtual void SendSerializedMalwareDetails( | 150 void SendSerializedMalwareDetails(const std::string& serialized) override { |
| 151 const std::string& serialized) override { | |
| 152 DVLOG(1) << "SendSerializedMalwareDetails"; | 151 DVLOG(1) << "SendSerializedMalwareDetails"; |
| 153 run_loop_->Quit(); | 152 run_loop_->Quit(); |
| 154 run_loop_ = NULL; | 153 run_loop_ = NULL; |
| 155 serialized_ = serialized; | 154 serialized_ = serialized; |
| 156 } | 155 } |
| 157 | 156 |
| 158 // Used to synchronize SendSerializedMalwareDetails() with | 157 // Used to synchronize SendSerializedMalwareDetails() with |
| 159 // WaitForSerializedReport(). RunLoop::RunUntilIdle() is not sufficient | 158 // WaitForSerializedReport(). RunLoop::RunUntilIdle() is not sufficient |
| 160 // because the MessageLoop task queue completely drains at some point | 159 // because the MessageLoop task queue completely drains at some point |
| 161 // between the send and the wait. | 160 // between the send and the wait. |
| 162 void SetRunLoopToQuit(base::RunLoop* run_loop) { | 161 void SetRunLoopToQuit(base::RunLoop* run_loop) { |
| 163 DCHECK(run_loop_ == NULL); | 162 DCHECK(run_loop_ == NULL); |
| 164 run_loop_ = run_loop; | 163 run_loop_ = run_loop; |
| 165 } | 164 } |
| 166 | 165 |
| 167 const std::string& GetSerialized() { | 166 const std::string& GetSerialized() { |
| 168 return serialized_; | 167 return serialized_; |
| 169 } | 168 } |
| 170 | 169 |
| 171 private: | 170 private: |
| 172 virtual ~MockSafeBrowsingUIManager() {} | 171 ~MockSafeBrowsingUIManager() override {} |
| 173 | 172 |
| 174 std::string serialized_; | 173 std::string serialized_; |
| 175 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingUIManager); | 174 DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingUIManager); |
| 176 }; | 175 }; |
| 177 | 176 |
| 178 } // namespace. | 177 } // namespace. |
| 179 | 178 |
| 180 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { | 179 class MalwareDetailsTest : public ChromeRenderViewHostTestHarness { |
| 181 public: | 180 public: |
| 182 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 181 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 pb_resource = expected.add_resources(); | 683 pb_resource = expected.add_resources(); |
| 685 pb_resource->set_id(2); | 684 pb_resource->set_id(2); |
| 686 pb_resource->set_parent_id(3); | 685 pb_resource->set_parent_id(3); |
| 687 pb_resource->set_url(kSecondRedirectURL); | 686 pb_resource->set_url(kSecondRedirectURL); |
| 688 pb_resource = expected.add_resources(); | 687 pb_resource = expected.add_resources(); |
| 689 pb_resource->set_id(3); | 688 pb_resource->set_id(3); |
| 690 pb_resource->set_url(kFirstRedirectURL); | 689 pb_resource->set_url(kFirstRedirectURL); |
| 691 | 690 |
| 692 VerifyResults(actual, expected); | 691 VerifyResults(actual, expected); |
| 693 } | 692 } |
| OLD | NEW |