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

Side by Side Diff: chrome/browser/media/router/discovery/safe_dial_device_description_parser.h

Issue 2745653008: [Media Router] Parse device description xml in utility process (Closed)
Patch Set: resolve code review comments from Mark 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 2017 The Chromium Authors. All rights reserved.
imcheng 2017/03/22 00:31:46 Seems like this file should be in c/b/m/r/discover
zhaobin 2017/03/22 01:55:32 Done.
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_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSE R_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PARSE R_H_
7
8 #include "base/callback.h"
imcheng 2017/03/22 00:31:46 #include <memory> #include <string>
zhaobin 2017/03/22 01:55:32 Done.
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/optional.h"
12 #include "base/threading/thread_checker.h"
13 #include "chrome/common/media_router/dial_device_description.h"
14 #include "chrome/common/media_router/dial_device_description_parser.mojom.h"
15 #include "content/public/browser/utility_process_mojo_client.h"
16
17 namespace media_router {
18
19 // SafeDialDeviceDescriptionParser parses the given device description XML file
20 // safely via a utility process. This class runs on IO thread.
21 class SafeDialDeviceDescriptionParser
22 : public base::RefCounted<SafeDialDeviceDescriptionParser> {
imcheng 2017/03/22 00:31:46 why does this need to be ref counted?
zhaobin 2017/03/22 01:55:32 Done.
23 public:
24 // Callback function to be invoked when utility process finishes parsing
25 // device description XML.
26 // |result|: returns false if parsing fails.
imcheng 2017/03/22 00:31:47 s/result/success
zhaobin 2017/03/22 01:55:32 Done.
27 // |device_description|: device description object. Empty if parsing fails.
28 using DeviceDescriptionCallback = base::Callback<void(
29 bool result,
30 const base::Optional<media_router::DialDeviceDescription>&
31 device_description)>;
32
33 SafeDialDeviceDescriptionParser();
34
35 // Start parsing device description XML file in utility process.
36 void Start(const std::string& xml_text,
37 const DeviceDescriptionCallback& callback);
38
39 private:
40 friend class base::RefCounted<SafeDialDeviceDescriptionParser>;
41
42 ~SafeDialDeviceDescriptionParser();
43
44 // See SafeDialDeviceDescriptionParser::DeviceDescriptionCallback
45 void OnParseDeviceDescriptionComplete(
46 bool result,
imcheng 2017/03/22 00:31:46 s/result/success
zhaobin 2017/03/22 01:55:32 Done.
47 const base::Optional<media_router::DialDeviceDescription>&
48 device_description);
49
50 // TODO(crbug.com/702766): Add an enum type describing why utility process
51 // fails to parse device description xml.
52 void OnParseDeviceDescriptionFailed();
53
54 // Utility client used to send device description parsing task to the utility
55 // process.
56 std::unique_ptr<content::UtilityProcessMojoClient<
57 chrome::mojom::DialDeviceDescriptionParser>>
58 utility_process_mojo_client_;
59
60 // Only accessed on the IO thread.
61 DeviceDescriptionCallback device_description_callback_;
62
63 base::ThreadChecker thread_checker_;
64
65 DISALLOW_COPY_AND_ASSIGN(SafeDialDeviceDescriptionParser);
66 };
67
68 } // namespace media_router
69
70 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_SAFE_DIAL_DEVICE_DESCRIPTION_PA RSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698