Commit 9f963600 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Create InProgressDownloadManager when DownloadManagerService is created without full browser

When full browser is not launched, we should create InProgressDownloadManager
to handle all the operations.

BUG=842245

Change-Id: I2687000288c9459c8df8099ff4721a2b6755d96e
Reviewed-on: https://chromium-review.googlesource.com/c/1297237
Commit-Queue: Min Qin <qinmin@chromium.org>
Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602097}
parent 8ce89e44
......@@ -156,9 +156,7 @@ static jlong JNI_DownloadManagerService_Init(JNIEnv* env,
const JavaParamRef<jobject>& jobj,
jboolean is_full_browser_started) {
DownloadManagerService* service = DownloadManagerService::GetInstance();
service->Init(env, jobj);
if (is_full_browser_started)
service->OnFullBrowserStarted(env, jobj);
service->Init(env, jobj, is_full_browser_started);
return reinterpret_cast<intptr_t>(service);
}
......@@ -179,10 +177,14 @@ void DownloadManagerService::NotifyServiceStarted(
connector_ = std::move(connector);
}
void DownloadManagerService::Init(
JNIEnv* env,
jobject obj) {
void DownloadManagerService::Init(JNIEnv* env,
jobject obj,
bool is_full_browser_started) {
java_ref_.Reset(env, obj);
if (is_full_browser_started)
OnFullBrowserStarted(env, obj);
else
CreateInProgressDownloadManager();
}
void DownloadManagerService::OnFullBrowserStarted(JNIEnv* env, jobject obj) {
......@@ -257,11 +259,7 @@ void DownloadManagerService::OpenDownload(
return;
std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid);
content::DownloadManager* manager = GetDownloadManager(is_off_the_record);
if (!manager)
return;
download::DownloadItem* item = manager->GetDownloadByGuid(download_guid);
download::DownloadItem* item = GetDownload(download_guid, is_off_the_record);
if (!item)
return;
......@@ -440,12 +438,7 @@ void DownloadManagerService::OnDownloadRemoved(
void DownloadManagerService::ResumeDownloadInternal(
const std::string& download_guid, bool is_off_the_record) {
content::DownloadManager* manager = GetDownloadManager(is_off_the_record);
if (!manager) {
OnResumptionFailed(download_guid);
return;
}
download::DownloadItem* item = manager->GetDownloadByGuid(download_guid);
download::DownloadItem* item = GetDownload(download_guid, is_off_the_record);
if (!item) {
OnResumptionFailed(download_guid);
return;
......
......@@ -55,8 +55,10 @@ class DownloadManagerService
void NotifyServiceStarted(
std::unique_ptr<service_manager::Connector> connector);
// Called to Initialize this object.
void Init(JNIEnv* env, jobject obj);
// Called to Initialize this object. If |is_full_browser_started| is false,
// it means only the service manager is launched. OnFullBrowserStarted() will
// be called later when browser process fully launches.
void Init(JNIEnv* env, jobject obj, bool is_full_browser_started);
// Called when full browser process starts.
void OnFullBrowserStarted(JNIEnv* env, jobject obj);
......
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