Commit 610bf38c authored by lizeb's avatar lizeb Committed by Commit bot

Write the predictor state on shutdown on Android.

The predictor usually serializes its state on a clean shutdown, so doesn't on
Android. This fixes it.

BUG=467007

Review URL: https://codereview.chromium.org/1004093003

Cr-Commit-Position: refs/heads/master@{#321966}
parent 55c69e29
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/tab_android.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_content_client.h"
...@@ -32,14 +33,15 @@ void FlushCookiesOnIOThread( ...@@ -32,14 +33,15 @@ void FlushCookiesOnIOThread(
} }
void CommitPendingWritesForProfile(Profile* profile) { void CommitPendingWritesForProfile(Profile* profile) {
// Both of these calls are asynchronous. They may not finish (and may not // These calls are asynchronous. They may not finish (and may not even
// even start!) before the Android OS kills our process. But we can't wait // start!) before the Android OS kills our process. But we can't wait for them
// for them to finish because blocking the UI thread is illegal. // to finish because blocking the UI thread is illegal.
profile->GetPrefs()->CommitPendingWrite(); profile->GetPrefs()->CommitPendingWrite();
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE, content::BrowserThread::IO, FROM_HERE,
base::Bind(&FlushCookiesOnIOThread, base::Bind(&FlushCookiesOnIOThread,
make_scoped_refptr(profile->GetRequestContext()))); make_scoped_refptr(profile->GetRequestContext())));
profile->GetNetworkPredictor()->SaveStateForNextStartupAndTrim();
} }
} // namespace } // namespace
......
...@@ -868,6 +868,8 @@ void Predictor::SaveDnsPrefetchStateForNextStartupAndTrim( ...@@ -868,6 +868,8 @@ void Predictor::SaveDnsPrefetchStateForNextStartupAndTrim(
// Do at least one trim at shutdown, in case the user wasn't running long // Do at least one trim at shutdown, in case the user wasn't running long
// enough to do any regular trimming of referrers. // enough to do any regular trimming of referrers.
// TODO(lizeb): Should trimming really be done at each shutdown? This could be
// a frequent occurrence on Android.
TrimReferrersNow(); TrimReferrersNow();
SerializeReferrers(referral_list); SerializeReferrers(referral_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment