OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/signaling/chromoting_event.h" | 5 #include "remoting/signaling/chromoting_event.h" |
6 | 6 |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const char kKeyType[] = "type"; | 13 const char kKeyType[] = "type"; |
14 const char kKeyCpu[] = "cpu"; | 14 const char kKeyCpu[] = "cpu"; |
15 const char kKeyOs[] = "os"; | 15 const char kKeyOs[] = "os"; |
16 const char kKeyOsVersion[] = "os_version"; | 16 const char kKeyOsVersion[] = "os_version"; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 ChromotingEvent::ChromotingEvent() : values_map_(new base::DictionaryValue()) {} | 20 ChromotingEvent::ChromotingEvent() : values_map_(new base::DictionaryValue()) {} |
21 | 21 |
22 ChromotingEvent::ChromotingEvent(Type type) : ChromotingEvent() { | 22 ChromotingEvent::ChromotingEvent(Type type) : ChromotingEvent() { |
23 SetEnum(kKeyType, type); | 23 SetEnum(kKeyType, type); |
24 } | 24 } |
25 | 25 |
26 ChromotingEvent::ChromotingEvent(const ChromotingEvent& other) { | 26 ChromotingEvent::ChromotingEvent(const ChromotingEvent& other) { |
27 try_count_ = other.try_count_; | 27 try_count_ = other.try_count_; |
28 values_map_.reset(other.values_map_->DeepCopy()); | 28 values_map_ = other.values_map_->CreateDeepCopy(); |
29 } | 29 } |
30 | 30 |
31 ChromotingEvent::ChromotingEvent(ChromotingEvent&& other) { | 31 ChromotingEvent::ChromotingEvent(ChromotingEvent&& other) { |
32 try_count_ = other.try_count_; | 32 try_count_ = other.try_count_; |
33 values_map_ = std::move(other.values_map_); | 33 values_map_ = std::move(other.values_map_); |
34 } | 34 } |
35 | 35 |
36 ChromotingEvent::~ChromotingEvent() {} | 36 ChromotingEvent::~ChromotingEvent() {} |
37 | 37 |
38 ChromotingEvent& ChromotingEvent::operator=(const ChromotingEvent& other) { | 38 ChromotingEvent& ChromotingEvent::operator=(const ChromotingEvent& other) { |
39 if (this != &other) { | 39 if (this != &other) { |
40 try_count_ = other.try_count_; | 40 try_count_ = other.try_count_; |
41 values_map_.reset(other.values_map_->DeepCopy()); | 41 values_map_ = other.values_map_->CreateDeepCopy(); |
42 } | 42 } |
43 return *this; | 43 return *this; |
44 } | 44 } |
45 | 45 |
46 ChromotingEvent& ChromotingEvent::operator=(ChromotingEvent&& other) { | 46 ChromotingEvent& ChromotingEvent::operator=(ChromotingEvent&& other) { |
47 try_count_ = other.try_count_; | 47 try_count_ = other.try_count_; |
48 values_map_ = std::move(other.values_map_); | 48 values_map_ = std::move(other.values_map_); |
49 return *this; | 49 return *this; |
50 } | 50 } |
51 | 51 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #endif | 87 #endif |
88 SetEnum(kKeyOs, os); | 88 SetEnum(kKeyOs, os); |
89 } | 89 } |
90 | 90 |
91 void ChromotingEvent::IncrementTryCount() { | 91 void ChromotingEvent::IncrementTryCount() { |
92 try_count_++; | 92 try_count_++; |
93 } | 93 } |
94 | 94 |
95 std::unique_ptr<base::DictionaryValue> ChromotingEvent::CopyDictionaryValue() | 95 std::unique_ptr<base::DictionaryValue> ChromotingEvent::CopyDictionaryValue() |
96 const { | 96 const { |
97 return std::unique_ptr<base::DictionaryValue>(values_map_->DeepCopy()); | 97 return values_map_->CreateDeepCopy(); |
98 } | 98 } |
99 | 99 |
100 // static | 100 // static |
101 bool ChromotingEvent::IsEndOfSession(SessionState state) { | 101 bool ChromotingEvent::IsEndOfSession(SessionState state) { |
102 return state == SessionState::CLOSED || | 102 return state == SessionState::CLOSED || |
103 state == SessionState::CONNECTION_DROPPED || | 103 state == SessionState::CONNECTION_DROPPED || |
104 state == SessionState::CONNECTION_FAILED || | 104 state == SessionState::CONNECTION_FAILED || |
105 state == SessionState::CONNECTION_CANCELED; | 105 state == SessionState::CONNECTION_CANCELED; |
106 } | 106 } |
107 | 107 |
108 } // namespace remoting | 108 } // namespace remoting |
OLD | NEW |