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

Side by Side Diff: content/browser/payments/payment_app_context_impl.h

Issue 2557473003: PaymentApp: Factor out functions to serialize/deserialize manifest data. (Closed)
Patch Set: test Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "components/payments/payment_app.mojom.h" 13 #include "components/payments/payment_app.mojom.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/common/service_worker/service_worker_status_code.h"
16 #include "content/public/browser/payment_app_context.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 class PaymentAppManager; 20 class PaymentAppManager;
19 class ServiceWorkerContextWrapper; 21 class ServiceWorkerContextWrapper;
20 22
21 class CONTENT_EXPORT PaymentAppContext 23 class CONTENT_EXPORT PaymentAppContextImpl
22 : public base::RefCountedThreadSafe<PaymentAppContext> { 24 : NON_EXPORTED_BASE(public PaymentAppContext),
25 public base::RefCountedThreadSafe<PaymentAppContextImpl> {
23 public: 26 public:
24 explicit PaymentAppContext( 27 explicit PaymentAppContextImpl(
25 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); 28 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
26 29
27 // Shutdown must be called before deleting this. Call on the UI thread. 30 // Shutdown must be called before deleting this. Call on the UI thread.
28 void Shutdown(); 31 void Shutdown();
29 32
30 // Create a PaymentAppManager that is owned by this. Call on the UI 33 // Create a PaymentAppManager that is owned by this. Call on the UI
31 // thread. 34 // thread.
32 void CreateService( 35 void CreateService(
33 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 36 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
34 37
35 // Called by PaymentAppManager objects so that they can 38 // Called by PaymentAppManager objects so that they can
36 // be deleted. Call on the IO thread. 39 // be deleted. Call on the IO thread.
37 void ServiceHadConnectionError(PaymentAppManager* service); 40 void ServiceHadConnectionError(PaymentAppManager* service);
38 41
39 ServiceWorkerContextWrapper* service_worker_context() const; 42 ServiceWorkerContextWrapper* service_worker_context() const;
40 43
44 void GetAllManifests(const GetAllManifestsCallback& callback) override;
45 void GetAllManifestsOnIO(const GetAllManifestsCallback& callback);
46 void DidGetAllManifests(
47 const GetAllManifestsCallback& callback,
48 const std::vector<std::pair<int64_t, std::string>>& user_data,
49 ServiceWorkerStatusCode status);
50 void GetAll(const GetManifestsCallback& callback);
51
41 protected: 52 protected:
42 friend class base::RefCountedThreadSafe<PaymentAppContext>; 53 friend class base::RefCountedThreadSafe<PaymentAppContextImpl>;
43 friend class PaymentAppManagerTest; 54 friend class PaymentAppManagerTest;
44 virtual ~PaymentAppContext(); 55 virtual ~PaymentAppContextImpl();
45 56
46 private: 57 private:
47 void CreateServiceOnIOThread( 58 void CreateServiceOnIOThread(
48 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request); 59 mojo::InterfaceRequest<payments::mojom::PaymentAppManager> request);
49 60
50 void ShutdownOnIO(); 61 void ShutdownOnIO();
51 62
52 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 63 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
53 64
54 // The services are owned by this. They're either deleted 65 // The services are owned by this. They're either deleted
55 // during ShutdownOnIO or when the channel is closed via 66 // during ShutdownOnIO or when the channel is closed via
56 // ServiceHadConnectionError. Only accessed on the IO thread. 67 // ServiceHadConnectionError. Only accessed on the IO thread.
57 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_; 68 std::map<PaymentAppManager*, std::unique_ptr<PaymentAppManager>> services_;
58 69
59 DISALLOW_COPY_AND_ASSIGN(PaymentAppContext); 70 base::WeakPtrFactory<PaymentAppContextImpl> weak_ptr_factory_;
71
72 DISALLOW_COPY_AND_ASSIGN(PaymentAppContextImpl);
60 }; 73 };
61 74
62 } // namespace content 75 } // namespace content
63 76
64 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_H_ 77 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_CONTEXT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/payments/payment_app_context.cc ('k') | content/browser/payments/payment_app_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698