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

Side by Side Diff: chrome/browser/extensions/api/dial/device_description_fetcher.h

Issue 2756483007: [Device Discovery] Move files from browser/extensions/api/dial to browser/media/router/discovery/di… (Closed)
Patch Set: resolve code review comments from Devlin Created 3 years, 9 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 (c) 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 CHROME_BROWSER_EXTENSIONS_API_DIAL_DEVICE_DESCRIPTION_FETCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DIAL_DEVICE_DESCRIPTION_FETCHER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15 #include "url/gurl.h"
16
17 namespace net {
18 class URLFetcher;
19 class URLRequestContextGetter;
20 }
21
22 namespace extensions {
23 namespace api {
24 namespace dial {
25
26 struct DialDeviceDescriptionData;
27
28 // Used to make a single HTTP GET request with |device_description_url| to fetch
29 // a uPnP device description from a DIAL device. If successful, |success_cb| is
30 // invoked with the result; otherwise, |error_cb| is invoked with an error
31 // reason.
32 // This class is not thread safe.
33 class DeviceDescriptionFetcher : public net::URLFetcherDelegate {
34 public:
35 // Used to identify the net::URLFetcher instance for tests.
36 static constexpr int kURLFetcherIDForTest = 1;
37
38 // |request_context| is unowned; the caller must ensure that this object does
39 // not outlive it.
40 DeviceDescriptionFetcher(
41 const GURL& device_description_url,
42 net::URLRequestContextGetter* request_context,
43 base::OnceCallback<void(const DialDeviceDescriptionData&)> success_cb,
44 base::OnceCallback<void(const std::string&)> error_cb);
45
46 ~DeviceDescriptionFetcher() override;
47
48 void Start();
49
50 private:
51 // net::URLFetcherDelegate implementation.
52 void OnURLFetchComplete(const net::URLFetcher* source) override;
53 void OnURLFetchDownloadProgress(const net::URLFetcher* source,
54 int64_t current,
55 int64_t total,
56 int64_t current_network_bytes) override;
57 void OnURLFetchUploadProgress(const net::URLFetcher* source,
58 int64_t current,
59 int64_t total) override;
60
61 // Runs |error_cb_| with |message| and clears it.
62 void ReportError(const std::string& message);
63
64 const GURL device_description_url_;
65 const scoped_refptr<net::URLRequestContextGetter> request_context_;
66 base::ThreadChecker thread_checker_;
67
68 base::OnceCallback<void(const DialDeviceDescriptionData&)> success_cb_;
69 base::OnceCallback<void(const std::string&)> error_cb_;
70 std::unique_ptr<net::URLFetcher> fetcher_;
71 };
72
73 } // namespace dial
74 } // namespace api
75 } // namespace extensions
76
77 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAL_DEVICE_DESCRIPTION_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/api/dial/device_description_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698