Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "ash/public/cpp/app_launch_id.h" | 5 #include "ash/public/cpp/app_launch_id.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace ash { | 9 namespace ash { |
| 10 | 10 |
| 11 AppLaunchId::AppLaunchId(const std::string& app_id, | 11 AppLaunchId::AppLaunchId(const std::string& app_id, |
| 12 const std::string& launch_id) | 12 const std::string& launch_id) |
| 13 : app_id_(app_id), launch_id_(launch_id) { | 13 : app_id_(app_id), launch_id_(launch_id) { |
| 14 DCHECK(!app_id.empty()); | 14 DCHECK(launch_id.empty() || !app_id.empty()) << "launch ids require app ids."; |
| 15 } | 15 } |
| 16 | 16 |
| 17 AppLaunchId::AppLaunchId(const std::string& app_id) : app_id_(app_id) { | 17 AppLaunchId::AppLaunchId(const std::string& app_id) : app_id_(app_id) {} |
|
James Cook
2017/05/04 16:38:48
optional: = default (and below)
msw
2017/05/04 19:05:56
Doneish, it works for the empty-arg default ctor a
| |
| 18 DCHECK(!app_id.empty()); | |
| 19 } | |
| 20 | 18 |
| 21 AppLaunchId::AppLaunchId() {} | 19 AppLaunchId::AppLaunchId() {} |
| 22 | 20 |
| 23 AppLaunchId::~AppLaunchId() {} | 21 AppLaunchId::~AppLaunchId() {} |
| 24 | 22 |
| 23 bool AppLaunchId::operator==(const AppLaunchId& other) const { | |
| 24 return app_id_ == other.app_id_ && launch_id_ == other.launch_id_; | |
| 25 } | |
| 26 | |
| 27 bool AppLaunchId::operator!=(const AppLaunchId& other) const { | |
| 28 return !(*this == other); | |
| 29 } | |
| 30 | |
| 31 bool AppLaunchId::operator<(const AppLaunchId& other) const { | |
| 32 return app_id_ < other.app_id_ || | |
| 33 (app_id_ == other.app_id_ && launch_id_ < other.launch_id_); | |
| 34 } | |
| 35 | |
| 36 bool AppLaunchId::IsEmpty() const { | |
| 37 return app_id_.empty() && launch_id_.empty(); | |
| 38 } | |
| 39 | |
| 25 } // namespace ash | 40 } // namespace ash |
| OLD | NEW |