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

Side by Side Diff: chrome/browser/media/router/issue.h

Issue 2176613003: [Media Router] Clean up issues related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "chrome/browser/media/router/media_route.h" 12 #include "chrome/browser/media/router/media_route.h"
13 13
14 namespace media_router { 14 namespace media_router {
15 15
16 // The text that corresponds with an action a user can take for a Issue.
17 class IssueAction {
18 public:
19 enum Type {
20 TYPE_DISMISS,
21 TYPE_LEARN_MORE,
22 TYPE_MAX /* Denotes enum value boundary. */
23 };
24
25 explicit IssueAction(const Type type);
26 ~IssueAction();
27
28 Type type() const { return type_; }
29
30 bool Equals(const IssueAction& other) const { return type_ == other.type_; }
31
32 private:
33 Type type_;
34 };
35
36 // Contains the information relevant to an issue. 16 // Contains the information relevant to an issue.
37 class Issue { 17 class Issue {
38 public: 18 public:
39 using Id = std::string; 19 // TODO(imcheng): The ID field should really be owned by IssueManager.
20 using Id = int;
40 21
41 enum Severity { FATAL, WARNING, NOTIFICATION }; 22 // Possible actions for an Issue.
23 enum class ActionType {
mark a. foltz 2016/07/27 18:52:03 Or just Action, so Issue::Action::DISMISS, etc.
imcheng 2016/09/13 20:27:54 Done.
24 DISMISS,
25 // NOTE: If LEARN_MORE is set as a possible action for an Issue, then its
26 // |help_page_id_| must also be set to a valid value.
27 LEARN_MORE,
28 MAX /* Denotes enum value boundary. */
mark a. foltz 2016/07/27 18:52:03 NUM_VALUES? Also, add a comment that new Actions
imcheng 2016/09/13 20:27:54 Done.
29 };
42 30
43 // Creates a custom issue. 31 // Severity type of an Issue. A FATAL issue is considered blocking, although
32 // issues of lower severity may also be blocking.
33 enum class Severity { FATAL, WARNING, NOTIFICATION };
34
35 // Creates a new issue. A new ID is assigned to the issue created with this
36 // constructor.
44 // |title|: The title for the issue. 37 // |title|: The title for the issue.
45 // |message|: The optional description message for the issue.
46 // |default_action|: Default action user can take to resolve the issue. 38 // |default_action|: Default action user can take to resolve the issue.
47 // |secondary_actions|: Array of options user can take to resolve the
48 // issue. Can be empty. Currently only one secondary
49 // action is supported.
50 // |route_id|: The route id, or empty if global.
51 // |severity|: The severity of the issue. 39 // |severity|: The severity of the issue.
52 // |is_blocking|: True if the issue needs to be resolved before continuing.
53 // |help_page_id|: Required if one of the actions is learn-more. Passes in -1
54 // if the issue is not associated with a help page.
55 Issue(const std::string& title, 40 Issue(const std::string& title,
56 const std::string& message, 41 const ActionType& default_action,
57 const IssueAction& default_action, 42 Severity severity);
58 const std::vector<IssueAction>& secondary_actions,
59 const MediaRoute::Id& route_id,
60 const Severity severity,
61 bool is_blocking,
62 int help_page_id);
63
64 Issue(const Issue& other); 43 Issue(const Issue& other);
mark a. foltz 2016/07/27 18:52:03 Usually if an object implements the copy construct
imcheng 2016/09/13 20:27:54 My new design makes breaks Issue into ID and data.
65 44
66 ~Issue(); 45 ~Issue();
67 46
47 // Setters for optional arguments.
mark a. foltz 2016/07/27 18:52:03 All of the getters or setters are trivial; this co
imcheng 2016/09/13 20:27:54 Right. What I did in the latest PS is to take out
48 void set_message(const std::string& message) { message_ = message; }
49 void set_secondary_actions(const std::vector<ActionType>& secondary_actions) {
50 secondary_actions_ = secondary_actions;
51 }
52 void set_route_id(const MediaRoute::Id& route_id) { route_id_ = route_id; }
53 void set_is_blocking(bool is_blocking) { is_blocking_ = is_blocking; }
54 void set_help_page_id(int help_page_id) { help_page_id_ = help_page_id; }
55
68 // See constructor comments for more information about these fields. 56 // See constructor comments for more information about these fields.
69 const std::string& title() const { return title_; } 57 const std::string& title() const { return title_; }
70 const std::string& message() const { return message_; } 58 const std::string& message() const { return message_; }
71 IssueAction default_action() const { return default_action_; } 59 ActionType default_action() const { return default_action_; }
72 const std::vector<IssueAction>& secondary_actions() const { 60 const std::vector<ActionType>& secondary_actions() const {
73 return secondary_actions_; 61 return secondary_actions_;
74 } 62 }
75 MediaRoute::Id route_id() const { return route_id_; } 63 MediaRoute::Id route_id() const { return route_id_; }
76 Severity severity() const { return severity_; } 64 Severity severity() const { return severity_; }
77 const Issue::Id& id() const { return id_; } 65 const Issue::Id& id() const { return id_; }
78 bool is_blocking() const { return is_blocking_; } 66
79 bool is_global() const { return route_id_.empty(); }
80 int help_page_id() const { return help_page_id_; } 67 int help_page_id() const { return help_page_id_; }
81 68
82 bool Equals(const Issue& other) const; 69 bool operator==(const Issue& other) const { return id_ == other.id_; }
mark a. foltz 2016/07/27 18:52:03 I think this is an okay definition of equals as lo
imcheng 2016/09/13 20:27:54 The ID is tripping things up here and doesn't play
70 bool operator!=(const Issue& other) const { return id_ != other.id_; }
71
72 // Returns |true| if the issue needs to be resolved before continuing.
73 bool IsBlocking() const;
mark a. foltz 2016/07/27 18:52:03 This shoudn't be necessary if is_blocking is initi
imcheng 2016/09/13 20:27:54 I now set is_blocking to true in the constructor i
74
75 // Returns |true| if the issue is not associated with a route.
76 bool IsGlobal() const;
83 77
84 private: 78 private:
79 // ID assigned by the normal constructor.
80 Id id_;
81
82 // Required fields.
85 std::string title_; 83 std::string title_;
84 ActionType default_action_;
85 Severity severity_;
86
87 // Optional fields.
mark a. foltz 2016/07/27 18:52:03 I don't think this comment makes sense in context.
imcheng 2016/09/13 20:27:54 Removed the comments.
88 // Description message for the issue. Required.
86 std::string message_; 89 std::string message_;
87 IssueAction default_action_; 90
88 std::vector<IssueAction> secondary_actions_; 91 // Array of options the user can take to resolve the issue in addition to the
92 // default action. Can be empty. If non-empty, currently only one secondary
93 // action is supported.
94 std::vector<ActionType> secondary_actions_;
95
96 // ID of route associated with the Issue, or empty if no route is associated
97 // with it.
89 std::string route_id_; 98 std::string route_id_;
90 Severity severity_; 99
91 Issue::Id id_; 100 // |true| if the issue needs to be resolved before continuing. Note that an
101 // Issue is considered blocking if its severity is FATAL, even if
102 // |is_blocking_| is |false|. Defaults to |false|.
92 bool is_blocking_; 103 bool is_blocking_;
104
105 // ID of help page to link to, if one of the actions is LEARN_MORE. -1
106 // Otherwise. Defaults to -1.
mark a. foltz 2016/07/27 18:52:03 Declare constant for kUnknownHelpPageId?
imcheng 2016/09/13 20:27:54 Done.
93 int help_page_id_; 107 int help_page_id_;
94 }; 108 };
95 109
96 } // namespace media_router 110 } // namespace media_router
97 111
98 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_ 112 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/router/issue.cc » ('j') | chrome/browser/media/router/issue.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698