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

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

Issue 2833793002: Added AddDownload communication path and observers
Patch Set: 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(
28 BrowserContext* browser_context,
harkness 2017/04/20 12:25:16 peter@ : I didn't really want to save the browser_
29 BackgroundFetchContext* background_fetch_context);
25 ~BackgroundFetchClientProxy() override; 30 ~BackgroundFetchClientProxy() override;
26 31
32 // Returns a weak pointer that can be used to post tasks to the proxy.
33 base::WeakPtr<BackgroundFetchClientProxy> GetWeakPtr();
34
35 // Notify the BackgroundFetchClient that a new download item is available.
36 void AddDownload(const std::string& registration_id,
37 const BackgroundFetchOptions& options);
38
27 // BackgroundFetchClient::Delegate implementation. 39 // BackgroundFetchClient::Delegate implementation.
28 void CleanupAllTasks() override; 40 void CleanupAllTasks() override;
29 void CancelDownload(const std::string& registration_id) override; 41 void CancelDownload(const std::string& registration_id) override;
30 void PauseDownload(const std::string& registration_id) override; 42 void PauseDownload(const std::string& registration_id) override;
31 void ResumeDownload(const std::string& registration_id) override; 43 void ResumeDownload(const std::string& registration_id) override;
32 44
33 private: 45 private:
46 // The BackgroundFetchClientProxy is indirectly owned by the BrowserContext.
47 BrowserContext* browser_context_;
48
34 // The BackgroundFetchClientProxy is owned by the BackgroundFetchContext. 49 // The BackgroundFetchClientProxy is owned by the BackgroundFetchContext.
35 BackgroundFetchContext* background_fetch_context_; 50 BackgroundFetchContext* background_fetch_context_;
36 51
52 base::WeakPtrFactory<BackgroundFetchClientProxy> weak_ptr_factory_;
53
37 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientProxy); 54 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientProxy);
38 }; 55 };
39 56
40 } // namespace content 57 } // namespace content
41 58
42 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_ 59 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698