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

Side by Side Diff: content/browser/background_fetch/background_fetch_client_proxy.h

Issue 2833793002: Added AddDownload communication path and observers
Patch Set: Addressed comments and moved thrad jumps into the client proxy. Created 3 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_ 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/background_fetch_client.h" 12 #include "content/public/browser/background_fetch_client.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 class BackgroundFetchContext; 16 class BackgroundFetchContext;
17 class BrowserContext;
18 struct BackgroundFetchOptions;
16 19
17 // The BackgroundFetchClientProxy exists to proxy calls from the 20 // The BackgroundFetchClientProxy exists to proxy calls from the
18 // BackgroundFetchContext, which lives on the IO thread, to the 21 // BackgroundFetchContext, which lives on the IO thread, to the
19 // BackgroundFetchClient which lives on the UI thread and back through the 22 // BackgroundFetchClient which lives on the UI thread and back through the
20 // BackgroundFetchClient::Delegate. 23 // BackgroundFetchClient::Delegate.
21 class CONTENT_EXPORT BackgroundFetchClientProxy 24 class CONTENT_EXPORT BackgroundFetchClientProxy
22 : public BackgroundFetchClient::Delegate { 25 : public BackgroundFetchClient::Delegate {
23 public: 26 public:
24 explicit BackgroundFetchClientProxy(BackgroundFetchContext* context); 27 explicit BackgroundFetchClientProxy(
Peter Beverloo 2017/04/24 14:39:15 -explicit
28 BrowserContext* browser_context,
29 BackgroundFetchContext* background_fetch_context);
25 ~BackgroundFetchClientProxy() override; 30 ~BackgroundFetchClientProxy() override;
26 31
32 // Notify the BackgroundFetchClient that a new download item is available.
33 void AddDownload(const GURL& url,
34 const std::string& registration_id,
35 const BackgroundFetchOptions& options);
36
27 // BackgroundFetchClient::Delegate implementation. 37 // BackgroundFetchClient::Delegate implementation.
28 void CleanupAllTasks() override; 38 void CleanupAllTasks() override;
29 void CancelDownload(const std::string& registration_id) override; 39 void CancelDownload(const std::string& registration_id) override;
30 void PauseDownload(const std::string& registration_id) override; 40 void PauseDownload(const std::string& registration_id) override;
31 void ResumeDownload(const std::string& registration_id) override; 41 void ResumeDownload(const std::string& registration_id) override;
32 42
33 private: 43 private:
44 void AddDownloadOnIO(const GURL& url,
45 const std::string& registration_id,
46 const BackgroundFetchOptions& options);
47
34 // The BackgroundFetchClientProxy is owned by the BackgroundFetchContext. 48 // The BackgroundFetchClientProxy is owned by the BackgroundFetchContext.
35 BackgroundFetchContext* background_fetch_context_; 49 BackgroundFetchContext* background_fetch_context_;
36 50
51 // This is set during initialization and must be cleaned up by the
52 // BackgroundFetchContext during shutdown before the BrowserContext is
53 // destroyed.
54 BackgroundFetchClient* background_fetch_client_;
55
56 base::WeakPtrFactory<BackgroundFetchClientProxy> weak_ptr_factory_;
57
37 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientProxy); 58 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientProxy);
38 }; 59 };
39 60
40 } // namespace content 61 } // namespace content
41 62
42 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_ 63 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698