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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/sync/ChromiumSyncAdapter.java

Issue 843913006: Reverting due to Android builders breakage. Subsequent fixes did not fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.sync; 5 package org.chromium.chrome.browser.sync;
6 6
7 import android.accounts.Account; 7 import android.accounts.Account;
8 import android.app.Application; 8 import android.app.Application;
9 import android.content.AbstractThreadedSyncAdapter; 9 import android.content.AbstractThreadedSyncAdapter;
10 import android.content.ContentProviderClient; 10 import android.content.ContentProviderClient;
11 import android.content.ContentResolver; 11 import android.content.ContentResolver;
12 import android.content.Context; 12 import android.content.Context;
13 import android.content.SyncResult; 13 import android.content.SyncResult;
14 import android.os.Bundle; 14 import android.os.Bundle;
15 import android.os.Handler; 15 import android.os.Handler;
16 import android.util.Log; 16 import android.util.Log;
17 17
18 import com.google.protos.ipc.invalidation.Types; 18 import com.google.protos.ipc.invalidation.Types;
19 19
20 import org.chromium.base.ThreadUtils; 20 import org.chromium.base.ThreadUtils;
21 import org.chromium.base.VisibleForTesting; 21 import org.chromium.base.VisibleForTesting;
22 import org.chromium.base.annotations.SuppressFBWarnings;
23 import org.chromium.base.library_loader.ProcessInitException; 22 import org.chromium.base.library_loader.ProcessInitException;
24 import org.chromium.chrome.browser.invalidation.InvalidationServiceFactory; 23 import org.chromium.chrome.browser.invalidation.InvalidationServiceFactory;
25 import org.chromium.chrome.browser.profiles.Profile; 24 import org.chromium.chrome.browser.profiles.Profile;
26 import org.chromium.content.app.ContentApplication; 25 import org.chromium.content.app.ContentApplication;
27 import org.chromium.content.browser.BrowserStartupController; 26 import org.chromium.content.browser.BrowserStartupController;
28 import org.chromium.sync.signin.ChromeSigninController; 27 import org.chromium.sync.signin.ChromeSigninController;
29 28
30 import java.util.concurrent.Semaphore; 29 import java.util.concurrent.Semaphore;
31 import java.util.concurrent.TimeUnit; 30 import java.util.concurrent.TimeUnit;
32 31
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 syncResult.stats.numIoExceptions++; 95 syncResult.stats.numIoExceptions++;
97 } 96 }
98 } 97 }
99 98
100 private void startBrowserProcess( 99 private void startBrowserProcess(
101 final BrowserStartupController.StartupCallback callback, 100 final BrowserStartupController.StartupCallback callback,
102 final SyncResult syncResult, Semaphore semaphore) { 101 final SyncResult syncResult, Semaphore semaphore) {
103 try { 102 try {
104 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 103 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
105 @Override 104 @Override
106 @SuppressFBWarnings("DM_EXIT")
107 public void run() { 105 public void run() {
108 ContentApplication.initCommandLine(getContext()); 106 ContentApplication.initCommandLine(getContext());
109 if (mAsyncStartup) { 107 if (mAsyncStartup) {
110 try { 108 try {
111 BrowserStartupController.get(mApplication) 109 BrowserStartupController.get(mApplication)
112 .startBrowserProcessesAsync(callback); 110 .startBrowserProcessesAsync(callback);
113 } catch (ProcessInitException e) { 111 } catch (ProcessInitException e) {
114 Log.e(TAG, "Unable to load native library.", e); 112 Log.e(TAG, "Unable to load native library.", e);
115 System.exit(-1); 113 System.exit(-1);
116 } 114 }
117 } else { 115 } else {
118 startBrowserProcessesSync(callback); 116 startBrowserProcessesSync(callback);
119 } 117 }
120 } 118 }
121 }); 119 });
122 } catch (RuntimeException e) { 120 } catch (RuntimeException e) {
123 // It is still unknown why we ever experience this. See http://crbug .com/180044. 121 // It is still unknown why we ever experience this. See http://crbug .com/180044.
124 Log.w(TAG, "Got exception when trying to request a sync. Informing A ndroid system.", e); 122 Log.w(TAG, "Got exception when trying to request a sync. Informing A ndroid system.", e);
125 // Using numIoExceptions so Android will treat this as a soft error. 123 // Using numIoExceptions so Android will treat this as a soft error.
126 syncResult.stats.numIoExceptions++; 124 syncResult.stats.numIoExceptions++;
127 semaphore.release(); 125 semaphore.release();
128 } 126 }
129 } 127 }
130 128
131 @SuppressFBWarnings("DM_EXIT")
132 private void startBrowserProcessesSync( 129 private void startBrowserProcessesSync(
133 final BrowserStartupController.StartupCallback callback) { 130 final BrowserStartupController.StartupCallback callback) {
134 try { 131 try {
135 BrowserStartupController.get(mApplication).startBrowserProcessesSync (false); 132 BrowserStartupController.get(mApplication).startBrowserProcessesSync (false);
136 } catch (ProcessInitException e) { 133 } catch (ProcessInitException e) {
137 Log.e(TAG, "Unable to load native library.", e); 134 Log.e(TAG, "Unable to load native library.", e);
138 System.exit(-1); 135 System.exit(-1);
139 } 136 }
140 new Handler().post(new Runnable() { 137 new Handler().post(new Runnable() {
141 @Override 138 @Override
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 InvalidationServiceFactory.getForProfile(Profile.getLastUsedProfile()) 188 InvalidationServiceFactory.getForProfile(Profile.getLastUsedProfile())
192 .requestSyncFromNativeChrome(objectSource, objectId, version, pa yload); 189 .requestSyncFromNativeChrome(objectSource, objectId, version, pa yload);
193 } 190 }
194 191
195 @VisibleForTesting 192 @VisibleForTesting
196 public void requestSyncForAllTypes() { 193 public void requestSyncForAllTypes() {
197 InvalidationServiceFactory.getForProfile(Profile.getLastUsedProfile()) 194 InvalidationServiceFactory.getForProfile(Profile.getLastUsedProfile())
198 .requestSyncFromNativeChromeForAllTypes(); 195 .requestSyncFromNativeChromeForAllTypes();
199 } 196 }
200 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698