Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
|
scheib
2012/05/30 16:41:21
2012
| |
| 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 CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_ | |
| 6 #define CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "ipc/ipc_param_traits.h" | |
| 10 #include "ipc/ipc_message_macros.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 // The source of a mouse lock request | |
|
scheib
2012/05/30 16:41:21
Punctuation:
http://google-styleguide.googlecode.c
| |
| 16 enum MouseLockSource { | |
| 17 // Lock requested with a user gesture | |
| 18 USER_GESTURE, | |
|
scheib
2012/05/30 16:41:21
These enum names are too generic for the content n
| |
| 19 // Lock requested not from a user gesture | |
| 20 NOT_USER_GESTURE | |
| 21 }; | |
| 22 | |
| 23 // The source of an unlock request | |
| 24 enum MouseUnlockSource { | |
| 25 // The target requested the unlock | |
| 26 TARGET, | |
| 27 // User requested unlock by pressing ESC or initial state | |
| 28 NOT_TARGET | |
| 29 }; | |
| 30 | |
| 31 } // namespace content | |
| 32 | |
| 33 // param traits for serialization over IPC | |
|
scheib
2012/05/30 16:41:21
As you mention, the implementation should be place
| |
| 34 namespace IPC { | |
| 35 template<> | |
| 36 struct ParamTraits<content::MouseLockSource> { | |
| 37 typedef content::MouseLockSource param_type; | |
|
scheib
2012/05/30 16:41:21
IMHO the typedef param_type makes this code less r
| |
| 38 static void Write(Message* m, const param_type& p) { | |
| 39 m->WriteInt(static_cast<int>(p)); | |
| 40 } | |
| 41 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
| 42 int type; | |
| 43 if (!m->ReadInt(iter, &type)) | |
| 44 return false; | |
| 45 *p = static_cast<param_type>(type); | |
| 46 return true; | |
| 47 } | |
| 48 static void Log(const param_type& p, std::string* l) { | |
| 49 std::string source; | |
| 50 switch (p) { | |
| 51 case content::USER_GESTURE: | |
| 52 source = "USER_GESTURE"; | |
| 53 break; | |
| 54 case content::NOT_USER_GESTURE: | |
| 55 source = "NOT_USER_GESTURE"; | |
| 56 break; | |
| 57 } | |
| 58 LogParam(source, l); | |
| 59 } | |
| 60 }; | |
| 61 | |
| 62 template<> | |
| 63 struct ParamTraits<content::MouseUnlockSource> { | |
| 64 typedef content::MouseUnlockSource param_type; | |
| 65 static void Write(Message* m, const param_type& p) { | |
| 66 m->WriteInt(static_cast<int>(p)); | |
| 67 } | |
| 68 static bool Read(const Message* m, PickleIterator* iter, param_type* p) { | |
| 69 int type; | |
| 70 if (!m->ReadInt(iter, &type)) | |
| 71 return false; | |
| 72 *p = static_cast<param_type>(type); | |
| 73 return true; | |
| 74 } | |
| 75 static void Log(const param_type& p, std::string* l) { | |
| 76 std::string source; | |
| 77 switch (p) { | |
| 78 case content::TARGET: | |
| 79 source = "TARGET"; | |
| 80 break; | |
| 81 case content::NOT_TARGET: | |
| 82 source = "NOT_TARGET"; | |
| 83 break; | |
| 84 } | |
| 85 LogParam(source, l); | |
| 86 } | |
| 87 }; | |
| 88 } | |
| 89 | |
| 90 #endif /* CONTENT_COMMON_MOUSE_LOCK_REQUEST_H_ */ | |
| OLD | NEW |