OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 #include "net/android/simple_cache_activity_status_notifier.h" | |
6 | |
7 #include "base/android/jni_android.h" | |
8 #include "base/basictypes.h" | |
9 #include "base/bind.h" | |
10 #include "base/bind_helpers.h" | |
11 #include "base/callback.h" | |
12 #include "base/logging.h" | |
13 #include "base/message_loop.h" | |
14 #include "base/message_loop_proxy.h" | |
15 #include "base/task_runner.h" | |
16 | |
Philippe
2013/04/23 11:34:25
Nit: no blank line here.
felipeg
2013/04/23 13:10:13
Done.
| |
17 #include "jni/SimpleCacheActivityStatusNotifier_jni.h" | |
18 | |
19 namespace net { | |
20 | |
21 SimpleCacheActivityStatusNotifier::SimpleCacheActivityStatusNotifier( | |
22 const ActivityStatusChangedCallback& notify_callback) : | |
Philippe
2013/04/23 11:34:25
Nit: The ':' should be on the line below.
felipeg
2013/04/23 13:10:13
Done.
| |
23 notify_callback_(notify_callback) { | |
24 JNIEnv* env = base::android::AttachCurrentThread(); | |
25 CHECK(env); | |
Philippe
2013/04/23 11:34:25
Nit: DCHECK() should be enough.
felipeg
2013/04/23 13:10:13
Done.
| |
26 java_obj_.Reset( | |
27 Java_SimpleCacheActivityStatusNotifier_newInstance( | |
28 env, reinterpret_cast<jint>(this))); | |
29 } | |
30 | |
31 SimpleCacheActivityStatusNotifier::~SimpleCacheActivityStatusNotifier() { | |
gavinp
2013/04/23 11:02:04
Why no thread check here?
Philippe
2013/04/23 11:34:25
+1 for a thread check here.
felipeg
2013/04/23 13:10:13
Done.
| |
32 JNIEnv* env = base::android::AttachCurrentThread(); | |
33 CHECK(env); | |
34 Java_SimpleCacheActivityStatusNotifier_prepareToBeDestroyed( | |
35 env, java_obj_.obj()); | |
36 } | |
37 | |
38 void SimpleCacheActivityStatusNotifier::NotifyActivityStatusChanged( | |
39 JNIEnv* env, | |
40 jobject obj, | |
41 jint j_new_activity_status) { | |
42 DCHECK(io_thread_checker_.CalledOnValidThread()); | |
43 ActivityStatus new_activity_status = | |
44 static_cast<ActivityStatus>(j_new_activity_status); | |
45 if (!notify_callback_.is_null()) | |
Philippe
2013/04/23 11:34:25
Can we DCHECK(!notify_callback_.is_null()) in the
felipeg
2013/04/23 13:10:13
Done.
| |
46 notify_callback_.Run(new_activity_status); | |
47 } | |
48 | |
49 // static | |
50 bool SimpleCacheActivityStatusNotifier::Register(JNIEnv* env) { | |
51 return RegisterNativesImpl(env); | |
52 } | |
53 | |
54 } // namespace net | |
OLD | NEW |