| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.services.gcm; | 5 package org.chromium.chrome.browser.services.gcm; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.annotation.SuppressLint; | 8 import android.annotation.SuppressLint; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.os.AsyncTask; | 10 import android.os.AsyncTask; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 */ | 30 */ |
| 31 public class InvalidationGcmUpstreamSender extends GcmUpstreamSenderService { | 31 public class InvalidationGcmUpstreamSender extends GcmUpstreamSenderService { |
| 32 private static final String TAG = "InvalidationGcmUpstream"; | 32 private static final String TAG = "InvalidationGcmUpstream"; |
| 33 | 33 |
| 34 // GCM Payload Limit in bytes. | 34 // GCM Payload Limit in bytes. |
| 35 private static final int GCM_PAYLOAD_LIMIT = 4000; | 35 private static final int GCM_PAYLOAD_LIMIT = 4000; |
| 36 | 36 |
| 37 @Override | 37 @Override |
| 38 public void deliverMessage(final String to, final Bundle data) { | 38 public void deliverMessage(final String to, final Bundle data) { |
| 39 @Nullable | 39 @Nullable |
| 40 Account account = ChromeSigninController.get().getSignedInUser(); | 40 Account account = ChromeSigninController.get(this).getSignedInUser(); |
| 41 if (account == null) { | 41 if (account == null) { |
| 42 // This should never happen, because this code should only be run if
a user is | 42 // This should never happen, because this code should only be run if
a user is |
| 43 // signed-in. | 43 // signed-in. |
| 44 Log.w(TAG, "No signed-in user; cannot send message to data center"); | 44 Log.w(TAG, "No signed-in user; cannot send message to data center"); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 | 47 |
| 48 final Bundle dataToSend = createDeepCopy(data); | 48 final Bundle dataToSend = createDeepCopy(data); |
| 49 final Context applicationContext = getApplicationContext(); | 49 final Context applicationContext = getApplicationContext(); |
| 50 | 50 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 @SuppressLint("ParcelClassLoader") | 108 @SuppressLint("ParcelClassLoader") |
| 109 private Bundle createDeepCopy(Bundle original) { | 109 private Bundle createDeepCopy(Bundle original) { |
| 110 Parcel temp = Parcel.obtain(); | 110 Parcel temp = Parcel.obtain(); |
| 111 original.writeToParcel(temp, 0); | 111 original.writeToParcel(temp, 0); |
| 112 temp.setDataPosition(0); | 112 temp.setDataPosition(0); |
| 113 Bundle copy = temp.readBundle(); | 113 Bundle copy = temp.readBundle(); |
| 114 temp.recycle(); | 114 temp.recycle(); |
| 115 return copy; | 115 return copy; |
| 116 } | 116 } |
| 117 } | 117 } |
| OLD | NEW |