| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 #ifndef OMAHA_TOOLS_SRC_OMAHACOMPATIBILITY_CONSOLE_WRITER_H_ | |
| 17 #define OMAHA_TOOLS_SRC_OMAHACOMPATIBILITY_CONSOLE_WRITER_H_ | |
| 18 | |
| 19 #include <Windows.h> | |
| 20 #include <tchar.h> | |
| 21 #include "omaha/common/synchronized.h" | |
| 22 #include "omaha/common/debug.h" | |
| 23 #include "omaha/common/logging.h" | |
| 24 #include "omaha/worker/ping_event.h" | |
| 25 #include "omaha/tools/omahacompatibility/common/ping_observer.h" | |
| 26 | |
| 27 namespace omaha { | |
| 28 | |
| 29 // Observer that writes to the console. It also remembers | |
| 30 // the result for install and update completed event. | |
| 31 class ConsoleWriter : public PingObserver { | |
| 32 public: | |
| 33 explicit ConsoleWriter(const CString& app_guid) | |
| 34 : app_guid_(app_guid), | |
| 35 install_completed_(false), | |
| 36 install_result_(PingEvent::EVENT_RESULT_ERROR), | |
| 37 update_completed_(false), | |
| 38 update_result_(PingEvent::EVENT_RESULT_ERROR) {} | |
| 39 virtual ~ConsoleWriter() {} | |
| 40 virtual void Observe(const AppRequestData& data); | |
| 41 | |
| 42 // Indicates if a install complete event has been received. | |
| 43 bool install_completed() const { | |
| 44 return install_completed_; | |
| 45 } | |
| 46 PingEvent::Results install_result() const { | |
| 47 return install_result_; | |
| 48 } | |
| 49 | |
| 50 // Indicates if a update complete event has been received. | |
| 51 bool update_completed() const { | |
| 52 return update_completed_; | |
| 53 } | |
| 54 PingEvent::Results update_result() const { | |
| 55 return update_result_; | |
| 56 } | |
| 57 | |
| 58 private: | |
| 59 bool IsInstallCompletedEvent(const CString& app_guid, | |
| 60 const PingEvent& ping); | |
| 61 bool IsUpdateCompletedEvent(const CString& app_guid, | |
| 62 const PingEvent& ping); | |
| 63 CString PingResultToString(PingEvent::Results result); | |
| 64 CString PingTypeToString(PingEvent::Types type); | |
| 65 | |
| 66 CString app_guid_; | |
| 67 LLock lock_; | |
| 68 PingEvent::Results install_result_; | |
| 69 bool install_completed_; | |
| 70 PingEvent::Results update_result_; | |
| 71 bool update_completed_; | |
| 72 }; | |
| 73 | |
| 74 } // namespace omaha | |
| 75 | |
| 76 #endif // OMAHA_TOOLS_SRC_OMAHACOMPATIBILITY_CONSOLE_WRITER_H_ | |
| OLD | NEW |