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

Issue 14373019: Add base/android/activity_status.cc (Closed)

Created:
7 years, 8 months ago by digit1
Modified:
7 years, 7 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, tfarina
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

Add base/android/activity_status.cc This patch adds a small thread-safe wrapper around the Java org.chromium.base.ActivityStatus that can be used to listen to activity state changes from native code. This uses a base::ObserverListThreadSafe to guarantee that listeners can be registered on any threads, and that their OnActivityStateChange() method will always be called on the thread that created them. + Ensure both C++ and Java always use the same constants when it comes to ActivityState values. R=felipeg@chromium.org, gavinp@chromium.org, pasko@google.com, pliard@chromium.org BUG=233536

Patch Set 1 #

Patch Set 2 : fix bug #

Total comments: 28

Patch Set 3 : Switch to callback-based interface. #

Patch Set 4 : Add multi-threaded unit test #

Patch Set 5 : formatting #

Total comments: 6

Patch Set 6 : remove RefCountedThreadSafe + ASSERT_* calls in subroutines #

Patch Set 7 : Address Marcus' nits + formatting #

Total comments: 16

Patch Set 8 : Address nits #

Patch Set 9 : formatting #

Total comments: 1

Patch Set 10 : rebase + comment updates #

Patch Set 11 : Removed un-necessary RunLoop nesting in unit test. #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+432 lines, -8 lines) Patch
A base/android/activity_state_list.h View 1 2 3 4 5 6 7 8 9 1 chunk +16 lines, -0 lines 0 comments Download
A base/android/activity_status.h View 1 2 3 4 5 6 7 8 1 chunk +97 lines, -0 lines 4 comments Download
A base/android/activity_status.cc View 1 2 3 4 5 6 7 8 1 chunk +66 lines, -0 lines 0 comments Download
A base/android/activity_status_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +175 lines, -0 lines 0 comments Download
M base/android/base_jni_registrar.cc View 3 chunks +3 lines, -1 line 0 comments Download
A base/android/java/src/org/chromium/base/ActivityState.template View 1 2 3 4 5 6 1 chunk +14 lines, -0 lines 0 comments Download
M base/android/java/src/org/chromium/base/ActivityStatus.java View 1 2 3 4 5 6 7 2 chunks +38 lines, -7 lines 0 comments Download
M base/base.gyp View 1 2 3 4 5 6 7 8 9 4 chunks +21 lines, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 26 (0 generated)
digit1
7 years, 8 months ago (2013-04-25 13:35:31 UTC) #1
digit1
Note: I'm working on adding a decent unit test for this, but please take a ...
7 years, 8 months ago (2013-04-25 13:36:20 UTC) #2
gavinp
On 2013/04/25 13:36:20, digit1 wrote: > Note: I'm working on adding a decent unit test ...
7 years, 8 months ago (2013-04-25 13:52:37 UTC) #3
digit1
Thanks, the second patch adds a single-threaded unit test that actually found a real bug ...
7 years, 8 months ago (2013-04-25 17:00:47 UTC) #4
felipeg_google
Are you sure that we want to use a singleton ? I mean, I know ...
7 years, 8 months ago (2013-04-25 18:16:08 UTC) #5
gavinp
All nits. LGTM. You'll have to add a base/android/OWNER or base/OWNER reviewer to land this. ...
7 years, 8 months ago (2013-04-26 07:37:53 UTC) #6
felipeg
LGTM On 2013/04/26 07:37:53, gavinp wrote: > All nits. > > LGTM. > > You'll ...
7 years, 8 months ago (2013-04-26 09:29:41 UTC) #7
digit1
https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status.cc File base/android/activity_status.cc (right): https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status.cc#newcode9 base/android/activity_status.cc:9: #include "base/memory/singleton.h" On 2013/04/26 07:37:53, gavinp wrote: > Not ...
7 years, 8 months ago (2013-04-26 12:32:40 UTC) #8
digit1
Hello Marcus and Jonathan, can I ask you to review the base/android/ changes in this ...
7 years, 8 months ago (2013-04-26 12:35:04 UTC) #9
gavinp
My old LGTM still stands. Thanks! https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status_unittest.cc File base/android/activity_status_unittest.cc (right): https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status_unittest.cc#newcode12 base/android/activity_status_unittest.cc:12: namespace base { ...
7 years, 8 months ago (2013-04-26 12:38:48 UTC) #10
bulach
lgtm, truly just nits.. thanks! https://chromiumcodereview.appspot.com/14373019/diff/23001/base/android/activity_status.h File base/android/activity_status.h (right): https://chromiumcodereview.appspot.com/14373019/diff/23001/base/android/activity_status.h#newcode59 base/android/activity_status.h:59: Listener(const StateChangeCallback& callback); nit: ...
7 years, 8 months ago (2013-04-26 12:57:06 UTC) #11
digit1
https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status_unittest.cc File base/android/activity_status_unittest.cc (right): https://chromiumcodereview.appspot.com/14373019/diff/4001/base/android/activity_status_unittest.cc#newcode54 base/android/activity_status_unittest.cc:54: DCHECK(env != NULL); Yes, I believe that's why I ...
7 years, 8 months ago (2013-04-26 13:25:55 UTC) #12
Philippe
lgtm, thanks David!
7 years, 8 months ago (2013-04-26 13:29:02 UTC) #13
joth
https://codereview.chromium.org/14373019/diff/37002/base/android/activity_state_list.h File base/android/activity_state_list.h (right): https://codereview.chromium.org/14373019/diff/37002/base/android/activity_state_list.h#newcode4 base/android/activity_state_list.h:4: there's some standard "no mutliple include guard" comment we ...
7 years, 8 months ago (2013-04-26 20:29:09 UTC) #14
brettw
https://chromiumcodereview.appspot.com/14373019/diff/37002/base/base.gyp File base/base.gyp (right): https://chromiumcodereview.appspot.com/14373019/diff/37002/base/base.gyp#newcode1157 base/base.gyp:1157: 'target_name': 'base_java_activity_state', This adds a new target. It isn't ...
7 years, 8 months ago (2013-04-27 05:16:41 UTC) #15
digit1
https://chromiumcodereview.appspot.com/14373019/diff/37002/base/android/activity_state_list.h File base/android/activity_state_list.h (right): https://chromiumcodereview.appspot.com/14373019/diff/37002/base/android/activity_state_list.h#newcode4 base/android/activity_state_list.h:4: I've added them, but generally speaking this kind of ...
7 years, 7 months ago (2013-04-29 12:22:10 UTC) #16
joth
replies to my comments lg2m https://chromiumcodereview.appspot.com/14373019/diff/51001/base/android/activity_state_list.h File base/android/activity_state_list.h (right): https://chromiumcodereview.appspot.com/14373019/diff/51001/base/android/activity_state_list.h#newcode5 base/android/activity_state_list.h:5: #define BASE_ANDROID_ACTIVITY_STATE_H yeah rather ...
7 years, 7 months ago (2013-04-29 16:41:23 UTC) #17
digit1
I've updated the file according to joth's and brett's recommendations. Please take a look. Thanks.
7 years, 7 months ago (2013-05-02 16:06:52 UTC) #18
joth
base/android lgtm, although I'm seeing diff error on some files in the most-recent patchset https://chromiumcodereview.appspot.com/14373019/diff/58001/base/android/java/src/org/chromium/base/ActivityStatus.java
7 years, 7 months ago (2013-05-02 17:16:01 UTC) #19
digit1
Thanks, I can't reproduce the multi-threaded unit test freeze locally. I've removed a non-necessary nested ...
7 years, 7 months ago (2013-05-02 17:57:42 UTC) #20
brettw
owners lgtm
7 years, 7 months ago (2013-05-02 20:26:12 UTC) #21
Philippe
On 2013/05/02 20:26:12, brettw wrote: > owners lgtm The failures we are seeing on the ...
7 years, 7 months ago (2013-05-03 14:05:55 UTC) #22
Philippe
On 2013/05/03 14:05:55, Philippe wrote: > On 2013/05/02 20:26:12, brettw wrote: > > owners lgtm ...
7 years, 7 months ago (2013-05-03 14:06:44 UTC) #23
tfarina
https://codereview.chromium.org/14373019/diff/69002/base/android/activity_status.h File base/android/activity_status.h (right): https://codereview.chromium.org/14373019/diff/69002/base/android/activity_status.h#newcode52 base/android/activity_status.h:52: BASE_EXPORT class ActivityStatus { I think it is more ...
7 years, 7 months ago (2013-05-06 14:22:16 UTC) #24
Philippe
https://codereview.chromium.org/14373019/diff/69002/base/android/activity_status.h File base/android/activity_status.h (right): https://codereview.chromium.org/14373019/diff/69002/base/android/activity_status.h#newcode52 base/android/activity_status.h:52: BASE_EXPORT class ActivityStatus { On 2013/05/06 14:22:16, tfarina wrote: ...
7 years, 7 months ago (2013-05-06 14:40:02 UTC) #25
Philippe
7 years, 7 months ago (2013-05-06 15:03:24 UTC) #26
On 2013/05/06 14:40:02, Philippe wrote:
>
https://codereview.chromium.org/14373019/diff/69002/base/android/activity_sta...
> File base/android/activity_status.h (right):
> 
>
https://codereview.chromium.org/14373019/diff/69002/base/android/activity_sta...
> base/android/activity_status.h:52: BASE_EXPORT class ActivityStatus {
> On 2013/05/06 14:22:16, tfarina wrote:
> > I think it is more common class BASE_EXPORT, no?
> 
> Indeed, that's why I recently landed  https://codereview.chromium.org/14948004
> :)
> 
> It broke the android component build downstream.
> 
>
https://codereview.chromium.org/14373019/diff/69002/base/android/activity_sta...
> base/android/activity_status.h:56: class Listener {
> On 2013/05/06 14:22:16, tfarina wrote:
> > could you move this into its own header file? ActivityStatusListener? We
> > generally try to avoid nested classes for this kind of interface.
> 
> Sure. This will be a good change. Clients don't need to pull  all these things
> since they just have to instantiate Listener to listen for events. I will send
> you the CL.

Please also note that this CL was already submitted as r198124. Therefore I'm
closing this issue.

Powered by Google App Engine
This is Rietveld 408576698