Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Side by Side Diff: components/dom_distiller/core/distiller_unittest.cc

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/thread_task_runner_handle.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "components/dom_distiller/core/article_distillation_update.h" 18 #include "components/dom_distiller/core/article_distillation_update.h"
18 #include "components/dom_distiller/core/distiller.h" 19 #include "components/dom_distiller/core/distiller.h"
19 #include "components/dom_distiller/core/distiller_page.h" 20 #include "components/dom_distiller/core/distiller_page.h"
20 #include "components/dom_distiller/core/fake_distiller_page.h" 21 #include "components/dom_distiller/core/fake_distiller_page.h"
21 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 22 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
22 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 23 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
23 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
24 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 url_ = url; 230 url_ = url;
230 callback_ = callback; 231 callback_ = callback;
231 if (!delay_fetch_) { 232 if (!delay_fetch_) {
232 PostCallbackTask(); 233 PostCallbackTask();
233 } 234 }
234 } 235 }
235 236
236 void PostCallbackTask() { 237 void PostCallbackTask() {
237 ASSERT_TRUE(base::MessageLoop::current()); 238 ASSERT_TRUE(base::MessageLoop::current());
238 ASSERT_FALSE(callback_.is_null()); 239 ASSERT_FALSE(callback_.is_null());
239 base::MessageLoop::current()->PostTask( 240 base::ThreadTaskRunnerHandle::Get()->PostTask(
240 FROM_HERE, base::Bind(callback_, responses_[url_])); 241 FROM_HERE, base::Bind(callback_, responses_[url_]));
241 } 242 }
242 243
243 private: 244 private:
244 std::map<string, string> responses_; 245 std::map<string, string> responses_;
245 string url_; 246 string url_;
246 URLFetcherCallback callback_; 247 URLFetcherCallback callback_;
247 bool delay_fetch_; 248 bool delay_fetch_;
248 }; 249 };
249 250
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 692
692 ASSERT_TRUE(distiller_page); 693 ASSERT_TRUE(distiller_page);
693 // Post the task to execute javascript and then delete the distiller. 694 // Post the task to execute javascript and then delete the distiller.
694 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get()); 695 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get());
695 distiller_.reset(); 696 distiller_.reset();
696 697
697 base::MessageLoop::current()->RunUntilIdle(); 698 base::MessageLoop::current()->RunUntilIdle();
698 } 699 }
699 700
700 } // namespace dom_distiller 701 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_page.cc ('k') | components/dom_distiller/core/dom_distiller_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698