Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/gcm_driver/gcm_driver_android.h" | 5 #include "components/gcm_driver/gcm_driver_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 void GCMDriverAndroid::WakeFromSuspendForHeartbeat(bool wake) { | 162 void GCMDriverAndroid::WakeFromSuspendForHeartbeat(bool wake) { |
| 163 } | 163 } |
| 164 | 164 |
| 165 GCMClient::Result GCMDriverAndroid::EnsureStarted( | 165 GCMClient::Result GCMDriverAndroid::EnsureStarted( |
| 166 GCMClient::StartMode start_mode) { | 166 GCMClient::StartMode start_mode) { |
| 167 // TODO(johnme): Maybe we should check if GMS is available? | 167 // TODO(johnme): Maybe we should check if GMS is available? |
| 168 return GCMClient::SUCCESS; | 168 return GCMClient::SUCCESS; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void GCMDriverAndroid::RegisterImpl( | 171 void GCMDriverAndroid::RegisterImpl( |
| 172 const std::string& app_id, | 172 const std::string& app_id, const std::vector<std::string>& sender_ids) { |
| 173 const std::vector<std::string>& sender_ids) { | 173 CHECK(sender_ids.size() == 1); |
|
jianli
2015/02/10 23:19:25
Is web push messaging the only client for Android?
johnme
2015/02/12 19:15:25
Push API is the only client I can find for GCMDriv
| |
| 174 JNIEnv* env = AttachCurrentThread(); | 174 JNIEnv* env = AttachCurrentThread(); |
| 175 Java_GCMDriver_register( | 175 Java_GCMDriver_register( |
| 176 env, java_ref_.obj(), | 176 env, java_ref_.obj(), |
| 177 ConvertUTF8ToJavaString(env, app_id).Release(), | 177 ConvertUTF8ToJavaString(env, app_id).Release(), |
| 178 ToJavaArrayOfStrings(env, sender_ids).obj()); | 178 ConvertUTF8ToJavaString(env, sender_ids[0]).Release()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void GCMDriverAndroid::UnregisterImpl(const std::string& app_id) { | 181 void GCMDriverAndroid::UnregisterImpl( |
| 182 const std::string& app_id, const std::vector<std::string>& sender_ids) { | |
| 183 CHECK(sender_ids.size() == 1); | |
| 182 JNIEnv* env = AttachCurrentThread(); | 184 JNIEnv* env = AttachCurrentThread(); |
| 183 Java_GCMDriver_unregister( | 185 Java_GCMDriver_unregister( |
| 184 env, java_ref_.obj(), | 186 env, java_ref_.obj(), |
| 185 ConvertUTF8ToJavaString(env, app_id).Release()); | 187 ConvertUTF8ToJavaString(env, app_id).Release(), |
| 188 ConvertUTF8ToJavaString(env, sender_ids[0]).Release()); | |
| 186 } | 189 } |
| 187 | 190 |
| 188 void GCMDriverAndroid::SendImpl(const std::string& app_id, | 191 void GCMDriverAndroid::SendImpl(const std::string& app_id, |
| 189 const std::string& receiver_id, | 192 const std::string& receiver_id, |
| 190 const GCMClient::OutgoingMessage& message) { | 193 const GCMClient::OutgoingMessage& message) { |
| 191 NOTIMPLEMENTED(); | 194 NOTIMPLEMENTED(); |
| 192 } | 195 } |
| 193 | 196 |
| 194 } // namespace gcm | 197 } // namespace gcm |
| OLD | NEW |