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

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: fix android build error 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_parser.mojom.h"
16 #include "content/public/browser/utility_process_mojo_client.h"
17
18 namespace media_router {
19
20 // SafeDialDeviceDescriptionParser parses the given device description XML file
21 // safely via a utility process. This class runs on IO thread.
22 class SafeDialDeviceDescriptionParser {
23 public:
24 // Callback function to be invoked when utility process finishes parsing
25 // device description XML.
26 // |success|: returns false if parsing fails.
27 // |device_description|: device description object. Empty if parsing fails.
28 using DeviceDescriptionCallback = chrome::mojom::DialDeviceDescriptionParser::
29 ParseDialDeviceDescriptionCallback;
30
31 SafeDialDeviceDescriptionParser();
32
33 // Start parsing device description XML file in utility process.
34 void Start(const std::string& xml_text,
35 const DeviceDescriptionCallback& callback);
36
37 private:
38 ~SafeDialDeviceDescriptionParser();
39
40 // See SafeDialDeviceDescriptionParser::DeviceDescriptionCallback
41 void OnParseDeviceDescriptionComplete(
42 chrome::mojom::DialDeviceDescriptionPtr device_description);
43
44 // TODO(crbug.com/702766): Add an enum type describing why utility process
45 // fails to parse device description xml.
46 void OnParseDeviceDescriptionFailed();
47
48 // Utility client used to send device description parsing task to the utility
49 // process.
50 std::unique_ptr<content::UtilityProcessMojoClient<
51 chrome::mojom::DialDeviceDescriptionParser>>
52 utility_process_mojo_client_;
53
54 // Only accessed on the IO thread.
55 DeviceDescriptionCallback device_description_callback_;
56
57 base::ThreadChecker thread_checker_;
58
59 DISALLOW_COPY_AND_ASSIGN(SafeDialDeviceDescriptionParser);
60 };
61
62 } // namespace media_router
63
64 #endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_SAFE_DIAL_DEVICE_DESCRIPTI ON_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698