Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher_group.h

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Patch Set: Fix a test. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H
6 #define EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H
7
8 #include <set>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h"
13 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
14 #include "extensions/common/user_script.h"
15
16 namespace content {
17 class BrowserContext;
18 }
19
20 // WebUIURLFetcherGroup receives a set of user script file load tasks, and
21 // starts a group of async URL fetchs. When all the fetches are done, it runs
22 // the callback from the owner of the group.
23 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.
24 public:
25 WebUIURLFetcherGroup(content::BrowserContext* context,
26 const base::Closure& callback);
27
28 // Starts URL requests to load the contents of several files from the
29 // associated render specified by |render_process_id, render_view_id|.
30 void Start(std::set<extensions::UserScript::File*> file_set,
31 int render_process_id,
32 int render_view_id);
33
34 private:
35 friend class base::RefCounted<WebUIURLFetcherGroup>;
36
37 virtual ~WebUIURLFetcherGroup();
38
39 // Called when each single URL fetch is complete. It also traces the number of
40 // complete fetches. If all the fetches are done, runs the callback function
41 // from the owner of this group.
42 void OnWebUIURLFetchComplete(extensions::UserScript::File* script_file,
43 bool success,
44 const std::string& data);
45
46 content::BrowserContext* context_;
47
48 // The number of complete fetchs.
49 size_t complete_fetchers_;
50
51 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
52 base::Closure callback_;
53
54 DISALLOW_COPY_AND_ASSIGN(WebUIURLFetcherGroup);
55 };
56
57 #endif // EXTENSIONS_BROWSER_WEB_UI_URL_FETCHER_GROUP_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698