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

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

Issue 2176613003: [Media Router] Clean up issues related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years 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
« no previous file with comments | « chrome/browser/media/router/issue.h ('k') | chrome/browser/media/router/issue_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/guid.h"
6 #include "chrome/browser/media/router/issue.h" 5 #include "chrome/browser/media/router/issue.h"
7 6
7 #include "base/atomic_sequence_num.h"
8
8 namespace media_router { 9 namespace media_router {
9 10
10 IssueAction::IssueAction(const IssueAction::Type type) : type_(type) { 11 namespace {
12 // ID generator for Issue.
13 base::StaticAtomicSequenceNumber g_next_issue_id;
11 } 14 }
12 15
13 IssueAction::~IssueAction() { 16 IssueInfo::IssueInfo()
17 : default_action(IssueInfo::Action::DISMISS),
18 severity(IssueInfo::Severity::NOTIFICATION),
19 is_blocking(false),
20 help_page_id(IssueInfo::kUnknownHelpPageId) {}
21
22 IssueInfo::IssueInfo(const std::string& title,
23 const Action default_action,
24 Severity severity)
25 : title(title),
26 default_action(default_action),
27 severity(severity),
28 is_blocking(severity == IssueInfo::Severity::FATAL),
29 help_page_id(IssueInfo::kUnknownHelpPageId) {}
30
31 IssueInfo::IssueInfo(const IssueInfo& other) = default;
32
33 IssueInfo::~IssueInfo() = default;
34
35 IssueInfo& IssueInfo::operator=(const IssueInfo& other) = default;
36
37 bool IssueInfo::operator==(const IssueInfo& other) const {
38 return title == other.title && default_action == other.default_action &&
39 severity == other.severity && message == other.message &&
40 secondary_actions == other.secondary_actions &&
41 route_id == other.route_id && is_blocking == other.is_blocking &&
42 help_page_id == other.help_page_id;
14 } 43 }
15 44
16 Issue::Issue(const std::string& title, 45 Issue::Issue(const IssueInfo& info)
17 const std::string& message, 46 : id_(g_next_issue_id.GetNext()), info_(info) {}
18 const IssueAction& default_action,
19 const std::vector<IssueAction>& secondary_actions,
20 const MediaRoute::Id& route_id,
21 const Issue::Severity severity,
22 bool is_blocking,
23 int help_page_id)
24 : title_(title),
25 message_(message),
26 default_action_(default_action),
27 secondary_actions_(secondary_actions),
28 route_id_(route_id),
29 severity_(severity),
30 id_(base::GenerateGUID()),
31 is_blocking_(is_blocking),
32 help_page_id_(help_page_id) {
33 DCHECK(!title_.empty());
34 DCHECK(severity_ != FATAL || is_blocking_) << "Severity is " << severity_;
35 47
36 // Check that the default and secondary actions are not of the same type. 48 Issue::~Issue() = default;
37 if (!secondary_actions_.empty())
38 DCHECK_NE(default_action_.type(), secondary_actions_[0].type());
39 }
40
41 Issue::Issue(const Issue& other) = default;
42
43 Issue::~Issue() {
44 }
45
46 bool Issue::Equals(const Issue& other) const {
47 return id_ == other.id_;
48 }
49 49
50 } // namespace media_router 50 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/issue.h ('k') | chrome/browser/media/router/issue_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698