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

Side by Side Diff: components/printing/renderer/print_web_view_helper.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 (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 "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/location.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
15 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/thread_task_runner_handle.h"
18 #include "components/printing/common/print_messages.h" 20 #include "components/printing/common/print_messages.h"
19 #include "content/public/common/web_preferences.h" 21 #include "content/public/common/web_preferences.h"
20 #include "content/public/renderer/render_frame.h" 22 #include "content/public/renderer/render_frame.h"
21 #include "content/public/renderer/render_thread.h" 23 #include "content/public/renderer/render_thread.h"
22 #include "content/public/renderer/render_view.h" 24 #include "content/public/renderer/render_view.h"
23 #include "grit/components_resources.h" 25 #include "grit/components_resources.h"
24 #include "net/base/escape.h" 26 #include "net/base/escape.h"
25 #include "printing/pdf_metafile_skia.h" 27 #include "printing/pdf_metafile_skia.h"
26 #include "printing/units.h" 28 #include "printing/units.h"
27 #include "third_party/WebKit/public/platform/WebSize.h" 29 #include "third_party/WebKit/public/platform/WebSize.h"
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 722 }
721 723
722 bool PrepareFrameAndViewForPrint::allowsBrokenNullLayerTreeView() const { 724 bool PrepareFrameAndViewForPrint::allowsBrokenNullLayerTreeView() const {
723 return true; 725 return true;
724 } 726 }
725 727
726 void PrepareFrameAndViewForPrint::didStopLoading() { 728 void PrepareFrameAndViewForPrint::didStopLoading() {
727 DCHECK(!on_ready_.is_null()); 729 DCHECK(!on_ready_.is_null());
728 // Don't call callback here, because it can delete |this| and WebView that is 730 // Don't call callback here, because it can delete |this| and WebView that is
729 // called didStopLoading. 731 // called didStopLoading.
730 base::MessageLoop::current()->PostTask( 732 base::ThreadTaskRunnerHandle::Get()->PostTask(
731 FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady, 733 FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady,
732 weak_ptr_factory_.GetWeakPtr())); 734 weak_ptr_factory_.GetWeakPtr()));
733 } 735 }
734 736
735 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame( 737 blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
736 blink::WebLocalFrame* parent, 738 blink::WebLocalFrame* parent,
737 blink::WebTreeScopeType scope, 739 blink::WebTreeScopeType scope,
738 const blink::WebString& name, 740 const blink::WebString& name,
739 blink::WebSandboxFlags sandboxFlags) { 741 blink::WebSandboxFlags sandboxFlags) {
740 blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this); 742 blink::WebFrame* frame = blink::WebLocalFrame::create(scope, this);
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 // document has been loaded. 1680 // document has been loaded.
1679 is_scripted_preview_delayed_ = true; 1681 is_scripted_preview_delayed_ = true;
1680 if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) { 1682 if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) {
1681 // Wait for DidStopLoading. Plugins may not know the correct 1683 // Wait for DidStopLoading. Plugins may not know the correct
1682 // |is_modifiable| value until they are fully loaded, which occurs when 1684 // |is_modifiable| value until they are fully loaded, which occurs when
1683 // DidStopLoading() is called. Defer showing the preview until then. 1685 // DidStopLoading() is called. Defer showing the preview until then.
1684 on_stop_loading_closure_ = 1686 on_stop_loading_closure_ =
1685 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, 1687 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview,
1686 base::Unretained(this)); 1688 base::Unretained(this));
1687 } else { 1689 } else {
1688 base::MessageLoop::current()->PostTask( 1690 base::ThreadTaskRunnerHandle::Get()->PostTask(
1689 FROM_HERE, base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, 1691 FROM_HERE, base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview,
1690 weak_ptr_factory_.GetWeakPtr())); 1692 weak_ptr_factory_.GetWeakPtr()));
1691 } 1693 }
1692 IPC::SyncMessage* msg = 1694 IPC::SyncMessage* msg =
1693 new PrintHostMsg_SetupScriptedPrintPreview(routing_id()); 1695 new PrintHostMsg_SetupScriptedPrintPreview(routing_id());
1694 msg->EnableMessagePumping(); 1696 msg->EnableMessagePumping();
1695 Send(msg); 1697 Send(msg);
1696 is_scripted_preview_delayed_ = false; 1698 is_scripted_preview_delayed_ = false;
1697 return; 1699 return;
1698 } 1700 }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 blink::WebConsoleMessage::LevelWarning, message)); 2070 blink::WebConsoleMessage::LevelWarning, message));
2069 return false; 2071 return false;
2070 } 2072 }
2071 2073
2072 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2074 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2073 // Reset counter on successful print. 2075 // Reset counter on successful print.
2074 count_ = 0; 2076 count_ = 0;
2075 } 2077 }
2076 2078
2077 } // namespace printing 2079 } // namespace printing
OLDNEW
« no previous file with comments | « components/precache/core/precache_fetcher_unittest.cc ('k') | components/printing/test/print_mock_render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698