How to get the loading percentage while loading a website?

177 views
Skip to first unread message

Feng Tianba

unread,
May 14, 2014, 10:08:51 PM5/14/14
to chromi...@chromium.org
I want to write a callback to implement getting the loading percentage while loading a website ,where or which function can I use?

Thiago Farina

unread,
May 14, 2014, 10:44:50 PM5/14/14
to Feng Tianba, Chromium-dev
On Wed, May 14, 2014 at 11:08 PM, Feng Tianba <fengtia...@gmail.com> wrote:
I want to write a callback to implement getting the loading percentage while loading a website ,where or which function can I use?
Did you try figuring out your question first?

I suggest you use cs.chromium.org and look at the content/ directory, you might find something there. Also look into net/ and into download directories, that might give you an idea as well.

You might also ask those questions in chromium-discussion in the future though.

Regards,

--
Thiago Farina

Avi Drissman

unread,
May 14, 2014, 11:15:05 PM5/14/14
to fengtia...@gmail.com, Chromium-dev
Check out RenderViewHostDelegate's DidChangeLoadProgress.

Avi


On Wed, May 14, 2014 at 10:08 PM, Feng Tianba <fengtia...@gmail.com> wrote:
I want to write a callback to implement getting the loading percentage while loading a website ,where or which function can I use?

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Feng Tianba

unread,
May 15, 2014, 1:38:52 AM5/15/14
to chromi...@chromium.org, Feng Tianba
Thank you ,next time I will post such question to chromium-discussion,can you give me a link of chromium-discussion?

在 2014年5月15日星期四UTC+8上午10时44分50秒,Thiago Farina写道:

Feng Tianba

unread,
May 15, 2014, 1:39:15 AM5/15/14
to chromi...@chromium.org, fengtia...@gmail.com
Thank you very much ,I will to check that ^.^

在 2014年5月15日星期四UTC+8上午11时15分05秒,Avi Drissman写道:

Feng Tianba

unread,
May 15, 2014, 3:30:34 AM5/15/14
to chromi...@chromium.org, fengtia...@gmail.com
Hi I have checked the function ,and I found this function has a parameter ,but I do not know how to use this function,I want to achieve the function is when the website loaded down, I can get the state.

在 2014年5月15日星期四UTC+8上午11时15分05秒,Avi Drissman写道:

Avi Drissman

unread,
May 15, 2014, 8:52:09 AM5/15/14
to fengtia...@gmail.com, Chromium-dev
That function is called when the renderer reports an update on page load progress. The WebContentsImpl is the RenderViewHostDelegate. When the progress goes through, it calls the WebContentsDelegate function LoadProgressChanged. You can follow it from there, and if you're embedding content, that is where you would hook in.

Feng Tianba

unread,
May 15, 2014, 9:25:28 PM5/15/14
to chromi...@chromium.org, fengtia...@gmail.com
Thand you very much,your explanation is quit useful.

在 2014年5月15日星期四UTC+8下午8时52分09秒,Avi Drissman写道:

Feng Tianba

unread,
May 15, 2014, 9:56:19 PM5/15/14
to chromi...@chromium.org, fengtia...@gmail.com
Avi, the LoadProgressChanged called when the progress goes through , but I want to get the load percentage while loading a webpage,how can I do that ?

在 2014年5月15日星期四UTC+8下午8时52分09秒,Avi Drissman写道:

Thiago Farina

unread,
May 15, 2014, 10:04:00 PM5/15/14
to Feng Tianba, Chromium-dev
On Thu, May 15, 2014 at 10:56 PM, Feng Tianba <fengtia...@gmail.com> wrote:
Avi, the LoadProgressChanged called when the progress goes through , but I want to get the load percentage while loading a webpage,how can I do that ?

Avi Drissman

unread,
May 15, 2014, 10:06:46 PM5/15/14
to Thiago Farina, Feng Tianba, Chromium-dev
Thiago is right. Right now, only our mobile platform actually uses load progress in the UI. I am rewiring this all now but I don't know to what extent it works right now.

If our existing code isn't granular enough, you may need to fiddle with it.


--

Feng Tianba

unread,
May 15, 2014, 10:52:55 PM5/15/14
to chromi...@chromium.org, Thiago Farina, Feng Tianba
That is, if I want to get the percentage of loading a webpage now, then I should write my own code,and no content API I can use. Is this ?

在 2014年5月16日星期五UTC+8上午10时06分46秒,Avi Drissman写道:

Feng Tianba

unread,
May 15, 2014, 11:03:36 PM5/15/14
to chromi...@chromium.org, fengtia...@gmail.com
Avi ,I want to get these date,such as before I load a webpage, I got 0,and when the webpage is loaded completely ,I got 1,I add such code in web_contents_impl.cc

void WebContentsImpl::DidChangeLoadProgress(double progress) {
#if defined(OS_ANDROID)
  if (delegate_)
  {
    delegate_->LoadProgressChanged(this, progress);
  }
#endif
  printf("\n\nexecute in didchangeloadprogress %s,%d,progress is %f\n\n", __FILE__, __LINE__, progress);
}

the printf was added by me ,but the progress value was always 0.

Avi Drissman

unread,
May 15, 2014, 11:18:30 PM5/15/14
to Feng Tianba, Chromium-dev
Thiago points out that this might be turned on only for Android, in which case you might need to manually go in and fix that for your use. Since you are building your own version, you shouldn't have an issue doing that.


--
Reply all
Reply to author
Forward
0 new messages