Chromium Code Reviews| Index: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h |
| diff --git a/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h b/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c55b5d3ac8311110dc5553db29c6798fc7ef83f4 |
| --- /dev/null |
| +++ b/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H |
| +#define EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H |
| + |
| +#include <set> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" |
| +#include "extensions/common/user_script.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +// WebUIURLFetcherGroup receives a set of user script file load tasks, and |
| +// starts a group of async URL fetchs. When all the fetches are done, it runs |
| +// the callback from the owner of the group. |
| +class WebUIURLFetcherGroup : public base::RefCounted<WebUIURLFetcherGroup> { |
|
Devlin
2015/04/16 20:19:28
Can you think of a way this could avoid being refc
Xi Han
2015/04/17 21:44:20
It needs to be RefCounted since in web_ui_url_fetc
Devlin
2015/04/17 22:05:05
The callback will be called by the WebUIURLFetcher
Xi Han
2015/04/17 22:28:24
I am confused. I assume the WebUIURLFetcherGroup w
Devlin
2015/04/17 22:40:15
If you recount it, yes, it will only be destroyed
Xi Han
2015/04/20 22:40:10
Removed.
|
| + public: |
| + WebUIURLFetcherGroup(content::BrowserContext* context, |
| + const base::Closure& callback); |
| + |
| + // Starts URL requests to load the contents of several files from the |
| + // associated render specified by |render_process_id, render_view_id|. |
| + void Start(std::set<extensions::UserScript::File*> file_set, |
| + int render_process_id, |
| + int render_view_id); |
| + |
| + private: |
| + friend class base::RefCounted<WebUIURLFetcherGroup>; |
| + |
| + virtual ~WebUIURLFetcherGroup(); |
| + |
| + // Called when each single URL fetch is complete. It also traces the number of |
| + // complete fetches. If all the fetches are done, runs the callback function |
| + // from the owner of this group. |
| + void OnWebUIURLFetchComplete(extensions::UserScript::File* script_file, |
| + bool success, |
| + const std::string& data); |
| + |
| + content::BrowserContext* context_; |
| + |
| + // The number of complete fetchs. |
| + size_t complete_fetchers_; |
| + |
| + ScopedVector<WebUIURLFetcher> fetchers_; |
|
Devlin
2015/04/16 20:19:28
Since WebUIURLFetcher is pretty much just a tiny w
Xi Han
2015/04/17 21:44:20
As discussed offline, I still adopt the way to kee
|
| + base::Closure callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebUIURLFetcherGroup); |
| +}; |
| + |
| +#endif // EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H |