| 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 "content/public/test/test_utils.h" | 5 #include "content/public/test/test_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "content/browser/storage_partition_impl.h" |
| 12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/test/test_launcher.h" | 15 #include "content/public/test/test_launcher.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Number of times to repost a Quit task so that the MessageLoop finishes up | 22 // Number of times to repost a Quit task so that the MessageLoop finishes up |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 render_view_host->ExecuteJavascriptInWebFrameCallbackResult( | 129 render_view_host->ExecuteJavascriptInWebFrameCallbackResult( |
| 129 string16(), // frame_xpath, | 130 string16(), // frame_xpath, |
| 130 UTF8ToUTF16(script), | 131 UTF8ToUTF16(script), |
| 131 base::Bind(&ScriptCallback::ResultCallback, base::Unretained(&observer))); | 132 base::Bind(&ScriptCallback::ResultCallback, base::Unretained(&observer))); |
| 132 base::MessageLoop* loop = base::MessageLoop::current(); | 133 base::MessageLoop* loop = base::MessageLoop::current(); |
| 133 loop->Run(); | 134 loop->Run(); |
| 134 return observer.result().Pass(); | 135 return observer.result().Pass(); |
| 135 } | 136 } |
| 136 | 137 |
| 138 net::CookieStore* GetCookieStoreForScheme( |
| 139 StoragePartition* storage_partition, |
| 140 const std::string& scheme) { |
| 141 return static_cast<StoragePartitionImpl*>(storage_partition)-> |
| 142 GetCookieStoreMap().GetForScheme(scheme); |
| 143 } |
| 144 |
| 137 MessageLoopRunner::MessageLoopRunner() | 145 MessageLoopRunner::MessageLoopRunner() |
| 138 : loop_running_(false), | 146 : loop_running_(false), |
| 139 quit_closure_called_(false) { | 147 quit_closure_called_(false) { |
| 140 } | 148 } |
| 141 | 149 |
| 142 MessageLoopRunner::~MessageLoopRunner() { | 150 MessageLoopRunner::~MessageLoopRunner() { |
| 143 } | 151 } |
| 144 | 152 |
| 145 void MessageLoopRunner::Run() { | 153 void MessageLoopRunner::Run() { |
| 146 // Do not run the message loop if our quit closure has already been called. | 154 // Do not run the message loop if our quit closure has already been called. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 217 |
| 210 seen_ = true; | 218 seen_ = true; |
| 211 if (!running_) | 219 if (!running_) |
| 212 return; | 220 return; |
| 213 | 221 |
| 214 message_loop_runner_->Quit(); | 222 message_loop_runner_->Quit(); |
| 215 running_ = false; | 223 running_ = false; |
| 216 } | 224 } |
| 217 | 225 |
| 218 } // namespace content | 226 } // namespace content |
| OLD | NEW |