|
@@ -149,6 +149,12 @@ void DownloadItem::Cancel() {
|
|
|
download_item_->Cancel(true);
|
|
|
}
|
|
|
|
|
|
+int64_t DownloadItem::GetCurrentBytesPerSecond() const {
|
|
|
+ if (!CheckAlive())
|
|
|
+ return 0;
|
|
|
+ return download_item_->CurrentSpeed();
|
|
|
+}
|
|
|
+
|
|
|
int64_t DownloadItem::GetReceivedBytes() const {
|
|
|
if (!CheckAlive())
|
|
|
return 0;
|
|
@@ -161,6 +167,12 @@ int64_t DownloadItem::GetTotalBytes() const {
|
|
|
return download_item_->GetTotalBytes();
|
|
|
}
|
|
|
|
|
|
+int DownloadItem::GetPercentComplete() const {
|
|
|
+ if (!CheckAlive())
|
|
|
+ return 0;
|
|
|
+ return download_item_->PercentComplete();
|
|
|
+}
|
|
|
+
|
|
|
std::string DownloadItem::GetMimeType() const {
|
|
|
if (!CheckAlive())
|
|
|
return "";
|
|
@@ -248,6 +260,12 @@ double DownloadItem::GetStartTime() const {
|
|
|
return download_item_->GetStartTime().InSecondsFSinceUnixEpoch();
|
|
|
}
|
|
|
|
|
|
+double DownloadItem::GetEndTime() const {
|
|
|
+ if (!CheckAlive())
|
|
|
+ return 0;
|
|
|
+ return download_item_->GetEndTime().InSecondsFSinceUnixEpoch();
|
|
|
+}
|
|
|
+
|
|
|
// static
|
|
|
gin::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder(
|
|
|
v8::Isolate* isolate) {
|
|
@@ -258,8 +276,11 @@ gin::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder(
|
|
|
.SetMethod("resume", &DownloadItem::Resume)
|
|
|
.SetMethod("canResume", &DownloadItem::CanResume)
|
|
|
.SetMethod("cancel", &DownloadItem::Cancel)
|
|
|
+ .SetMethod("getCurrentBytesPerSecond",
|
|
|
+ &DownloadItem::GetCurrentBytesPerSecond)
|
|
|
.SetMethod("getReceivedBytes", &DownloadItem::GetReceivedBytes)
|
|
|
.SetMethod("getTotalBytes", &DownloadItem::GetTotalBytes)
|
|
|
+ .SetMethod("getPercentComplete", &DownloadItem::GetPercentComplete)
|
|
|
.SetMethod("getMimeType", &DownloadItem::GetMimeType)
|
|
|
.SetMethod("hasUserGesture", &DownloadItem::HasUserGesture)
|
|
|
.SetMethod("getFilename", &DownloadItem::GetFilename)
|
|
@@ -276,7 +297,8 @@ gin::ObjectTemplateBuilder DownloadItem::GetObjectTemplateBuilder(
|
|
|
.SetMethod("getSaveDialogOptions", &DownloadItem::GetSaveDialogOptions)
|
|
|
.SetMethod("getLastModifiedTime", &DownloadItem::GetLastModifiedTime)
|
|
|
.SetMethod("getETag", &DownloadItem::GetETag)
|
|
|
- .SetMethod("getStartTime", &DownloadItem::GetStartTime);
|
|
|
+ .SetMethod("getStartTime", &DownloadItem::GetStartTime)
|
|
|
+ .SetMethod("getEndTime", &DownloadItem::GetEndTime);
|
|
|
}
|
|
|
|
|
|
const char* DownloadItem::GetTypeName() {
|