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

Side by Side Diff: media/base/android/media_player_bridge.h

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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
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 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void Prepare(); 98 virtual void Prepare();
99 void OnMediaPrepared(); 99 void OnMediaPrepared();
100 100
101 // Create the corresponding Java class instance. 101 // Create the corresponding Java class instance.
102 virtual void CreateJavaMediaPlayerBridge(); 102 virtual void CreateJavaMediaPlayerBridge();
103 103
104 // Get allowed operations from the player. 104 // Get allowed operations from the player.
105 virtual base::android::ScopedJavaLocalRef<jobject> GetAllowedOperations(); 105 virtual base::android::ScopedJavaLocalRef<jobject> GetAllowedOperations();
106 106
107 private: 107 private:
108 friend class MediaPlayerListener;
109
108 // Set the data source for the media player. 110 // Set the data source for the media player.
109 void SetDataSource(const std::string& url); 111 void SetDataSource(const std::string& url);
110 112
111 // Functions that implements media player control. 113 // Functions that implements media player control.
112 void StartInternal(); 114 void StartInternal();
113 void PauseInternal(); 115 void PauseInternal();
114 void SeekInternal(base::TimeDelta time); 116 void SeekInternal(base::TimeDelta time);
115 117
116 // Called when |time_update_timer_| fires. 118 // Called when |time_update_timer_| fires.
117 void OnTimeUpdateTimerFired(); 119 void OnTimeUpdateTimerFired();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bool can_pause_; 161 bool can_pause_;
160 bool can_seek_forward_; 162 bool can_seek_forward_;
161 bool can_seek_backward_; 163 bool can_seek_backward_;
162 164
163 // Cookies for |url_|. 165 // Cookies for |url_|.
164 std::string cookies_; 166 std::string cookies_;
165 167
166 // Java MediaPlayerBridge instance. 168 // Java MediaPlayerBridge instance.
167 base::android::ScopedJavaGlobalRef<jobject> j_media_player_bridge_; 169 base::android::ScopedJavaGlobalRef<jobject> j_media_player_bridge_;
168 170
169 base::RepeatingTimer<MediaPlayerBridge> time_update_timer_;
170
171 // Weak pointer passed to |listener_| for callbacks.
172 base::WeakPtrFactory<MediaPlayerBridge> weak_this_;
173
174 // Listener object that listens to all the media player events. 171 // Listener object that listens to all the media player events.
175 MediaPlayerListener listener_; 172 scoped_ptr<MediaPlayerListener> listener_;
176 173
177 // Whether player is currently using a surface. 174 // Whether player is currently using a surface.
178 bool is_surface_in_use_; 175 bool is_surface_in_use_;
179 176
180 friend class MediaPlayerListener; 177 base::RepeatingTimer<MediaPlayerBridge> time_update_timer_;
178
179 // Weak pointer passed to |listener_| for callbacks. NOTE: This must always
180 // be last so it's invalidated before other member variables might be
181 // accessed.
182 base::WeakPtrFactory<MediaPlayerBridge> weak_factory_;
183
181 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge); 184 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge);
182 }; 185 };
183 186
184 } // namespace media 187 } // namespace media
185 188
186 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ 189 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698