| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 /* | 5 /* |
| 6 * metrics_library.cc | 6 * metrics_library.cc |
| 7 * | 7 * |
| 8 * Created on: Dec 1, 2009 | 8 * Created on: Dec 1, 2009 |
| 9 * Author: sosa | 9 * Author: sosa |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #include "platform/metrics_collection/metrics_library.h" | 12 #include "metrics_library.h" |
| 13 | 13 |
| 14 #include <errno.h> | 14 #include <errno.h> |
| 15 #include <sys/file.h> | 15 #include <sys/file.h> |
| 16 #include <string.h> | 16 #include <string.h> |
| 17 #include <stdio.h> | 17 #include <stdio.h> |
| 18 | 18 |
| 19 #define READ_WRITE_ALL_FILE_FLAGS \ | 19 #define READ_WRITE_ALL_FILE_FLAGS \ |
| 20 (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) | 20 (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) |
| 21 | 21 |
| 22 static const char kAutotestPath[] = "/tmp/.chromeos-metrics-autotest"; | 22 static const char kAutotestPath[] = "/tmp/.chromeos-metrics-autotest"; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 curr_ptr += name.length() + 1; | 91 curr_ptr += name.length() + 1; |
| 92 strncpy(curr_ptr, value.c_str(), value.length()); | 92 strncpy(curr_ptr, value.c_str(), value.length()); |
| 93 if (write(chrome_fd, message, message_length) != message_length) | 93 if (write(chrome_fd, message, message_length) != message_length) |
| 94 PrintError("write", kChromePath, errno); | 94 PrintError("write", kChromePath, errno); |
| 95 | 95 |
| 96 // Release the file lock and close file | 96 // Release the file lock and close file |
| 97 if (flock(chrome_fd, LOCK_UN) < 0) | 97 if (flock(chrome_fd, LOCK_UN) < 0) |
| 98 PrintError("unlock", kChromePath, errno); | 98 PrintError("unlock", kChromePath, errno); |
| 99 close(chrome_fd); | 99 close(chrome_fd); |
| 100 } | 100 } |
| OLD | NEW |