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

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

Issue 2925063003: [Payments] Implement payment instrument icons (Closed)
Patch Set: rebase Created 3 years, 6 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 2017 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 CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
6 #define CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "components/payments/mojom/payment_app.mojom.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "net/url_request/url_fetcher.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "net/url_request/url_request_context_getter.h"
17 #include "third_party/skia/include/core/SkBitmap.h"
18
19 namespace content {
20
21 class PaymentInstrumentIconFetcher : private net::URLFetcherDelegate {
22 public:
23 using PaymentInstrumentIconFetcherCallback =
24 base::OnceCallback<void(const std::string&)>;
25
26 PaymentInstrumentIconFetcher() {}
27 ~PaymentInstrumentIconFetcher() override {}
please use gerrit instead 2017/06/08 21:34:11 Don't inline destructors for classes with complex
gogerald1 2017/06/09 14:23:24 Done.
28
29 // Starts fetching and decoding payment instrument icon from online. The
30 // result will be send back through |callback|.
31 // TODO(gogerald): Right now, we return the first fetchable and decodable icon
32 // with smallest available size. We may add more logic to choose appropriate
33 // icon according to icon size and our usage.
34 void start(const GURL& scope,
35 const std::vector<payments::mojom::ImageObjectPtr>& image_objects,
36 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
37 PaymentInstrumentIconFetcherCallback callback);
38
39 private:
40 void StartFromUIThread(
41 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
42 void PostCallbackToIOThread(const std::string& decoded_data);
43
44 // data_decoder::mojom::ImageDecoder::DecodeImageCallback.
45 void DecodeImageCallback(const SkBitmap& bitmap);
46
47 // Override net::URLFetcherDelegate.
48 void OnURLFetchComplete(const net::URLFetcher* source) override;
49
50 void FetchIcon();
51
52 // Scope of the service worker of the payment instrument belongs to.
53 GURL scope_;
54
55 // Declared set of image objects of the payment instrument.
56 std::vector<payments::mojom::ImageObjectPtr> image_objects_;
57
58 // The index of the currently checking image object in image_objects_.
59 size_t checking_image_object_index_;
please use gerrit instead 2017/06/08 21:34:11 Need to initialize in the constructor, otherwise i
gogerald1 2017/06/09 14:23:24 It was initialized in start() public interface,
60
61 // The callback to notify after complete.
62 PaymentInstrumentIconFetcherCallback callback_;
63
64 // The url request context getter for fetching icon from online.
65 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
66
67 // The url fetcher to fetch raw icon from online.
68 std::unique_ptr<net::URLFetcher> fetcher_;
69
70 DISALLOW_COPY_AND_ASSIGN(PaymentInstrumentIconFetcher);
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698