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

Side by Side Diff: android_webview/renderer/aw_execution_termination_filter.h

Issue 536593004: Revert "Merge 281715 "[Android WebView] Terminate execution of stuck JS ..."" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2062
Patch Set: Created 6 years, 3 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ANDROID_WEBVIEW_RENDERER_AW_EXECUTION_TERMINATION_FILTER_H_
6 #define ANDROID_WEBVIEW_RENDERER_AW_EXECUTION_TERMINATION_FILTER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/timer/timer.h"
10 #include "ipc/message_filter.h"
11
12 namespace base {
13 class MessageLoopProxy;
14 }
15
16 namespace v8 {
17 class Isolate;
18 }
19
20 namespace android_webview {
21
22 // The purpose of AwExecutionTerminationFilter is to attempt to terminate
23 // any JavaScript code that is stuck in a loop before doing a navigation
24 // originating from a Andoird WebView URL loading functions.
25 //
26 // This is how it works. AwExecutionTerminationFilter is created on render
27 // thread. It listens on IO thread for navigation requests coming from
28 // AwContents.loadUrl calls. On each such a request, it posts a delayed
29 // cancellable task on the IO thread's message loop and, at the same time, posts
30 // a cancellation task on the render thread's message loop. If render thread
31 // is not stuck, the cancellation task runs and cancels the delayed task.
32 // Otherwise, the delayed task runs and terminates execution of JS code
33 // from the IO thread.
34 class AwExecutionTerminationFilter : public IPC::MessageFilter {
35 public:
36 AwExecutionTerminationFilter(
37 const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
38 const scoped_refptr<base::MessageLoopProxy>& main_message_loop);
39
40 void SetRenderThreadIsolate(v8::Isolate* isolate);
41
42 private:
43 virtual ~AwExecutionTerminationFilter();
44
45 // IPC::MessageFilter methods.
46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
47
48 void OnCheckRenderThreadResponsiveness();
49 void StopTimerOnMainThread();
50 void StopTimer();
51 void TerminateExecution();
52
53 const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
54 const scoped_refptr<base::MessageLoopProxy> main_message_loop_;
55
56 v8::Isolate* render_thread_isolate_;
57 base::OneShotTimer<AwExecutionTerminationFilter> termination_timer_;
58
59 DISALLOW_COPY_AND_ASSIGN(AwExecutionTerminationFilter);
60 };
61
62 } // namespace android_webview
63
64 #endif // ANDROID_WEBVIEW_RENDERER_AW_EXECUTION_TERMINATION_FILTER_H_
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.cc ('k') | android_webview/renderer/aw_execution_termination_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698