Java Code Examples for org.chromium.net.NetworkChangeNotifier#addConnectionTypeObserver()

The following examples show how to use org.chromium.net.NetworkChangeNotifier#addConnectionTypeObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountManagerHelper.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void onGotAuthTokenResult(Account account, String authTokenType, String authToken,
        GetAuthTokenCallback callback, AtomicInteger numTries, AtomicBoolean errorEncountered,
        ConnectionRetry retry) {
    if (authToken != null || !errorEncountered.get() ||
            numTries.incrementAndGet() == MAX_TRIES ||
            !NetworkChangeNotifier.isInitialized()) {
        callback.tokenAvailable(authToken);
        return;
    }
    if (retry == null) {
        ConnectionRetry newRetry = new ConnectionRetry(account, authTokenType, callback,
                numTries, errorEncountered);
        NetworkChangeNotifier.addConnectionTypeObserver(newRetry);
    } else {
        NetworkChangeNotifier.addConnectionTypeObserver(retry);
    }
}
 
Example 2
Source File: AccountManagerHelper.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void onGotAuthTokenResult(Account account, String authTokenType, String authToken,
        GetAuthTokenCallback callback, AtomicInteger numTries, AtomicBoolean errorEncountered,
        ConnectionRetry retry) {
    if (authToken != null || !errorEncountered.get() ||
            numTries.incrementAndGet() == MAX_TRIES ||
            !NetworkChangeNotifier.isInitialized()) {
        callback.tokenAvailable(authToken);
        return;
    }
    if (retry == null) {
        ConnectionRetry newRetry = new ConnectionRetry(account, authTokenType, callback,
                numTries, errorEncountered);
        NetworkChangeNotifier.addConnectionTypeObserver(newRetry);
    } else {
        NetworkChangeNotifier.addConnectionTypeObserver(retry);
    }
}
 
Example 3
Source File: UmaSessionStats.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Starts a new session for logging.
 * @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
 * If null, UmaSessionStats does not record page loads and tab counts.
 */
public void startNewSession(TabModelSelector tabModelSelector) {
    ensureNativeInitialized();

    mTabModelSelector = tabModelSelector;
    if (mTabModelSelector != null) {
        mComponentCallbacks = new ComponentCallbacks() {
            @Override
            public void onLowMemory() {
                // Not required
            }

            @Override
            public void onConfigurationChanged(Configuration newConfig) {
                mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
            }
        };
        mContext.registerComponentCallbacks(mComponentCallbacks);
        mKeyboardConnected = mContext.getResources().getConfiguration()
                .keyboard != Configuration.KEYBOARD_NOKEYS;
        mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
            @Override
            public void onPageLoadFinished(Tab tab) {
                recordPageLoadStats(tab);
            }
        };
    }

    nativeUmaResumeSession(sNativeUmaSessionStats);
    NetworkChangeNotifier.addConnectionTypeObserver(this);
    updatePreferences();
    updateMetricsServiceState();
}
 
Example 4
Source File: ContextualSearchTabHelper.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private ContextualSearchTabHelper(Tab tab) {
    mTab = tab;
    tab.addObserver(this);
    // Connect to a network, unless under test.
    if (NetworkChangeNotifier.isInitialized()) {
        NetworkChangeNotifier.addConnectionTypeObserver(this);
    }
}
 
Example 5
Source File: ContextualSearchTabHelper.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private ContextualSearchTabHelper(Tab tab) {
    mTab = tab;
    tab.addObserver(this);
    // Connect to a network, unless under test.
    if (NetworkChangeNotifier.isInitialized()) {
        NetworkChangeNotifier.addConnectionTypeObserver(this);
    }
}
 
Example 6
Source File: OfflinePageTabObserver.java    From delion with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
void startObservingNetworkChanges() {
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}
 
Example 7
Source File: MinidumpUploadRetry.java    From delion with Apache License 2.0 4 votes vote down vote up
private MinidumpUploadRetry(Context context) {
    this.mContext = context;
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}
 
Example 8
Source File: OfflinePageTabObserver.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
void startObservingNetworkChanges() {
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}
 
Example 9
Source File: MinidumpUploadRetry.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private MinidumpUploadRetry(Context context) {
    this.mContext = context;
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}
 
Example 10
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
void startObservingNetworkChanges() {
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}
 
Example 11
Source File: MinidumpUploadRetry.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private MinidumpUploadRetry(
        Context context, CrashReportingPermissionManager permissionManager) {
    this.mContext = context;
    this.mPermissionManager = permissionManager;
    NetworkChangeNotifier.addConnectionTypeObserver(this);
}