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, ...@@ -156,9 +156,7 @@ static jlong JNI_DownloadManagerService_Init(JNIEnv* env,
const JavaParamRef<jobject>& jobj, const JavaParamRef<jobject>& jobj,
jboolean is_full_browser_started) { jboolean is_full_browser_started) {
DownloadManagerService* service = DownloadManagerService::GetInstance(); DownloadManagerService* service = DownloadManagerService::GetInstance();
service->Init(env, jobj); service->Init(env, jobj, is_full_browser_started);
if (is_full_browser_started)
service->OnFullBrowserStarted(env, jobj);
return reinterpret_cast<intptr_t>(service); return reinterpret_cast<intptr_t>(service);
} }
...@@ -179,10 +177,14 @@ void DownloadManagerService::NotifyServiceStarted( ...@@ -179,10 +177,14 @@ void DownloadManagerService::NotifyServiceStarted(
connector_ = std::move(connector); connector_ = std::move(connector);
} }
void DownloadManagerService::Init( void DownloadManagerService::Init(JNIEnv* env,
JNIEnv* env, jobject obj,
jobject obj) { bool is_full_browser_started) {
java_ref_.Reset(env, obj); java_ref_.Reset(env, obj);
if (is_full_browser_started)
OnFullBrowserStarted(env, obj);
else
CreateInProgressDownloadManager();
} }
void DownloadManagerService::OnFullBrowserStarted(JNIEnv* env, jobject obj) { void DownloadManagerService::OnFullBrowserStarted(JNIEnv* env, jobject obj) {
...@@ -257,11 +259,7 @@ void DownloadManagerService::OpenDownload( ...@@ -257,11 +259,7 @@ void DownloadManagerService::OpenDownload(
return; return;
std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid); std::string download_guid = ConvertJavaStringToUTF8(env, jdownload_guid);
content::DownloadManager* manager = GetDownloadManager(is_off_the_record); download::DownloadItem* item = GetDownload(download_guid, is_off_the_record);
if (!manager)
return;
download::DownloadItem* item = manager->GetDownloadByGuid(download_guid);
if (!item) if (!item)
return; return;
...@@ -440,12 +438,7 @@ void DownloadManagerService::OnDownloadRemoved( ...@@ -440,12 +438,7 @@ void DownloadManagerService::OnDownloadRemoved(
void DownloadManagerService::ResumeDownloadInternal( void DownloadManagerService::ResumeDownloadInternal(
const std::string& download_guid, bool is_off_the_record) { const std::string& download_guid, bool is_off_the_record) {
content::DownloadManager* manager = GetDownloadManager(is_off_the_record); download::DownloadItem* item = GetDownload(download_guid, is_off_the_record);
if (!manager) {
OnResumptionFailed(download_guid);
return;
}
download::DownloadItem* item = manager->GetDownloadByGuid(download_guid);
if (!item) { if (!item) {
OnResumptionFailed(download_guid); OnResumptionFailed(download_guid);
return; return;
......
...@@ -55,8 +55,10 @@ class DownloadManagerService ...@@ -55,8 +55,10 @@ class DownloadManagerService
void NotifyServiceStarted( void NotifyServiceStarted(
std::unique_ptr<service_manager::Connector> connector); std::unique_ptr<service_manager::Connector> connector);
// Called to Initialize this object. // Called to Initialize this object. If |is_full_browser_started| is false,
void Init(JNIEnv* env, jobject obj); // 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. // Called when full browser process starts.
void OnFullBrowserStarted(JNIEnv* env, jobject obj); 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