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

Side by Side Diff: content/browser/android/content_view_statics.cc

Issue 209033002: Merge 258544 "Fix crash introduced in https://codereview.chromiu..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
(...skipping 26 matching lines...) Expand all
37 // Note that this class is only accessed from the UI thread. 37 // Note that this class is only accessed from the UI thread.
38 class SuspendedProcessWatcher : public content::RenderProcessHostObserver { 38 class SuspendedProcessWatcher : public content::RenderProcessHostObserver {
39 public: 39 public:
40 40
41 // If the process crashes, stop watching the corresponding RenderProcessHost 41 // If the process crashes, stop watching the corresponding RenderProcessHost
42 // and ensure it doesn't get over-resumed. 42 // and ensure it doesn't get over-resumed.
43 virtual void RenderProcessExited(content::RenderProcessHost* host, 43 virtual void RenderProcessExited(content::RenderProcessHost* host,
44 base::ProcessHandle handle, 44 base::ProcessHandle handle,
45 base::TerminationStatus status, 45 base::TerminationStatus status,
46 int exit_code) OVERRIDE { 46 int exit_code) OVERRIDE {
47 std::vector<int>::iterator pos = std::find(suspended_processes_.begin(), 47 StopWatching(host);
48 suspended_processes_.end(), 48 }
49 host->GetID()); 49
50 DCHECK_NE(pos, suspended_processes_.end()); 50 virtual void RenderProcessHostDestroyed(
51 host->RemoveObserver(this); 51 content::RenderProcessHost* host) OVERRIDE {
52 suspended_processes_.erase(pos); 52 StopWatching(host);
53 } 53 }
54 54
55 // Suspends timers in all current render processes. 55 // Suspends timers in all current render processes.
56 void SuspendWebKitSharedTimers() { 56 void SuspendWebKitSharedTimers() {
57 DCHECK(suspended_processes_.empty()); 57 DCHECK(suspended_processes_.empty());
58 58
59 for (content::RenderProcessHost::iterator i( 59 for (content::RenderProcessHost::iterator i(
60 content::RenderProcessHost::AllHostsIterator()); 60 content::RenderProcessHost::AllHostsIterator());
61 !i.IsAtEnd(); i.Advance()) { 61 !i.IsAtEnd(); i.Advance()) {
62 content::RenderProcessHost* host = i.GetCurrentValue(); 62 content::RenderProcessHost* host = i.GetCurrentValue();
(...skipping 12 matching lines...) Expand all
75 content::RenderProcessHost* host = 75 content::RenderProcessHost* host =
76 content::RenderProcessHost::FromID(*it); 76 content::RenderProcessHost::FromID(*it);
77 DCHECK(host); 77 DCHECK(host);
78 host->RemoveObserver(this); 78 host->RemoveObserver(this);
79 host->Send(new ViewMsg_SetWebKitSharedTimersSuspended(false)); 79 host->Send(new ViewMsg_SetWebKitSharedTimersSuspended(false));
80 } 80 }
81 suspended_processes_.clear(); 81 suspended_processes_.clear();
82 } 82 }
83 83
84 private: 84 private:
85 void StopWatching(content::RenderProcessHost* host) {
86 std::vector<int>::iterator pos = std::find(suspended_processes_.begin(),
87 suspended_processes_.end(),
88 host->GetID());
89 DCHECK_NE(pos, suspended_processes_.end());
90 host->RemoveObserver(this);
91 suspended_processes_.erase(pos);
92 }
93
85 std::vector<int /* RenderProcessHost id */> suspended_processes_; 94 std::vector<int /* RenderProcessHost id */> suspended_processes_;
86 }; 95 };
87 96
88 base::LazyInstance<SuspendedProcessWatcher> g_suspended_processes_watcher = 97 base::LazyInstance<SuspendedProcessWatcher> g_suspended_processes_watcher =
89 LAZY_INSTANCE_INITIALIZER; 98 LAZY_INSTANCE_INITIALIZER;
90 99
91 } // namespace 100 } // namespace
92 101
93 // Returns the first substring consisting of the address of a physical location. 102 // Returns the first substring consisting of the address of a physical location.
94 static jstring FindAddress(JNIEnv* env, jclass clazz, jstring addr) { 103 static jstring FindAddress(JNIEnv* env, jclass clazz, jstring addr) {
(...skipping 14 matching lines...) Expand all
109 } 118 }
110 } 119 }
111 120
112 namespace content { 121 namespace content {
113 122
114 bool RegisterWebViewStatics(JNIEnv* env) { 123 bool RegisterWebViewStatics(JNIEnv* env) {
115 return RegisterNativesImpl(env); 124 return RegisterNativesImpl(env);
116 } 125 }
117 126
118 } // namespace content 127 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698