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 <jni.h> | 5 #include <jni.h> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "content/browser/android/content_view_statics.h" | 13 #include "content/browser/android/content_view_statics.h" |
| 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
14 #include "content/common/android/address_parser.h" | 15 #include "content/common/android/address_parser.h" |
15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_process_host_observer.h" | 18 #include "content/public/browser/render_process_host_observer.h" |
18 #include "jni/ContentViewStatics_jni.h" | 19 #include "jni/ContentViewStatics_jni.h" |
19 | 20 |
20 using base::android::ConvertJavaStringToUTF16; | 21 using base::android::ConvertJavaStringToUTF16; |
21 using base::android::ConvertUTF16ToJavaString; | 22 using base::android::ConvertUTF16ToJavaString; |
22 using base::android::JavaParamRef; | 23 using base::android::JavaParamRef; |
23 using base::android::ScopedJavaLocalRef; | 24 using base::android::ScopedJavaLocalRef; |
(...skipping 29 matching lines...) Expand all Loading... |
53 | 54 |
54 // Suspends timers in all current render processes. | 55 // Suspends timers in all current render processes. |
55 void SuspendWebKitSharedTimers() { | 56 void SuspendWebKitSharedTimers() { |
56 DCHECK(suspended_processes_.empty()); | 57 DCHECK(suspended_processes_.empty()); |
57 | 58 |
58 for (content::RenderProcessHost::iterator i( | 59 for (content::RenderProcessHost::iterator i( |
59 content::RenderProcessHost::AllHostsIterator()); | 60 content::RenderProcessHost::AllHostsIterator()); |
60 !i.IsAtEnd(); i.Advance()) { | 61 !i.IsAtEnd(); i.Advance()) { |
61 content::RenderProcessHost* host = i.GetCurrentValue(); | 62 content::RenderProcessHost* host = i.GetCurrentValue(); |
62 host->AddObserver(this); | 63 host->AddObserver(this); |
63 host->Send(new ViewMsg_SetWebKitSharedTimersSuspended(true)); | 64 host->GetRendererInterface()->SetWebKitSharedTimersSuspended(true); |
64 suspended_processes_.push_back(host->GetID()); | 65 suspended_processes_.push_back(host->GetID()); |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 // Resumes timers in processes that were previously stopped. | 69 // Resumes timers in processes that were previously stopped. |
69 void ResumeWebkitSharedTimers() { | 70 void ResumeWebkitSharedTimers() { |
70 for (std::vector<int>::const_iterator it = suspended_processes_.begin(); | 71 for (std::vector<int>::const_iterator it = suspended_processes_.begin(); |
71 it != suspended_processes_.end(); ++it) { | 72 it != suspended_processes_.end(); ++it) { |
72 content::RenderProcessHost* host = | 73 content::RenderProcessHost* host = |
73 content::RenderProcessHost::FromID(*it); | 74 content::RenderProcessHost::FromID(*it); |
74 DCHECK(host); | 75 DCHECK(host); |
75 host->RemoveObserver(this); | 76 host->RemoveObserver(this); |
76 host->Send(new ViewMsg_SetWebKitSharedTimersSuspended(false)); | 77 host->GetRendererInterface()->SetWebKitSharedTimersSuspended(false); |
77 } | 78 } |
78 suspended_processes_.clear(); | 79 suspended_processes_.clear(); |
79 } | 80 } |
80 | 81 |
81 private: | 82 private: |
82 void StopWatching(content::RenderProcessHost* host) { | 83 void StopWatching(content::RenderProcessHost* host) { |
83 std::vector<int>::iterator pos = std::find(suspended_processes_.begin(), | 84 std::vector<int>::iterator pos = std::find(suspended_processes_.begin(), |
84 suspended_processes_.end(), | 85 suspended_processes_.end(), |
85 host->GetID()); | 86 host->GetID()); |
86 DCHECK(pos != suspended_processes_.end()); | 87 DCHECK(pos != suspended_processes_.end()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 namespace content { | 122 namespace content { |
122 | 123 |
123 bool RegisterWebViewStatics(JNIEnv* env) { | 124 bool RegisterWebViewStatics(JNIEnv* env) { |
124 return RegisterNativesImpl(env); | 125 return RegisterNativesImpl(env); |
125 } | 126 } |
126 | 127 |
127 } // namespace content | 128 } // namespace content |
OLD | NEW |