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

Side by Side Diff: chrome/browser/media/router/discovery/dial/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 Derek 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.
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_DIAL_SAFE_DIAL_DEVICE_DESCRIPTION_ PARSER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_SAFE_DIAL_DEVICE_DESCRIPTION_ PARSER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/optional.h"
14 #include "base/threading/thread_checker.h"
15 #include "chrome/common/media_router/dial_device_description.h"
16 #include "chrome/common/media_router/dial_device_description_parser.mojom.h"
17 #include "content/public/browser/utility_process_mojo_client.h"
18
19 namespace media_router {
20
21 // SafeDialDeviceDescriptionParser parses the given device description XML file
22 // safely via a utility process. This class runs on IO thread.
23 class SafeDialDeviceDescriptionParser {
24 public:
25 // Callback function to be invoked when utility process finishes parsing
26 // device description XML.
27 // |success|: returns false if parsing fails.
28 // |device_description|: device description object. Empty if parsing fails.
29 using DeviceDescriptionCallback = base::Callback<void(
30 bool success,
31 const base::Optional<media_router::DialDeviceDescription>&
32 device_description)>;
33
34 SafeDialDeviceDescriptionParser();
35
36 // Start parsing device description XML file in utility process.
37 void Start(const std::string& xml_text,
38 const DeviceDescriptionCallback& callback);
39
40 private:
41 ~SafeDialDeviceDescriptionParser();
42
43 // See SafeDialDeviceDescriptionParser::DeviceDescriptionCallback
44 void OnParseDeviceDescriptionComplete(
45 bool success,
46 const base::Optional<media_router::DialDeviceDescription>&
47 device_description);
48
49 // TODO(crbug.com/702766): Add an enum type describing why utility process
50 // fails to parse device description xml.
51 void OnParseDeviceDescriptionFailed();
52
53 // Utility client used to send device description parsing task to the utility
54 // process.
55 std::unique_ptr<content::UtilityProcessMojoClient<
56 chrome::mojom::DialDeviceDescriptionParser>>
57 utility_process_mojo_client_;
58
59 // Only accessed on the IO thread.
60 DeviceDescriptionCallback device_description_callback_;
61
62 base::ThreadChecker thread_checker_;
63
64 DISALLOW_COPY_AND_ASSIGN(SafeDialDeviceDescriptionParser);
65 };
66
67 } // namespace media_router
68
69 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_SAFE_DIAL_DEVICE_DESCRIPTI ON_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698