Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: chromecast/crash/linux/synchronized_minidump_manager_unittest.cc

Issue 1553503002: Convert Pass()→std::move() in //chromecast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/crash/linux/synchronized_minidump_manager.h"
6
5 #include <fcntl.h> 7 #include <fcntl.h>
6 #include <stdint.h> 8 #include <stdint.h>
7 #include <stdio.h> // perror 9 #include <stdio.h> // perror
8 #include <stdlib.h> 10 #include <stdlib.h>
9 #include <sys/file.h> 11 #include <sys/file.h>
10 #include <sys/stat.h> // mkdir 12 #include <sys/stat.h> // mkdir
11 #include <sys/types.h> // 13 #include <sys/types.h>
12 #include <time.h> 14 #include <time.h>
13
14 #include <fstream> 15 #include <fstream>
16 #include <utility>
15 17
16 #include "base/base_paths.h" 18 #include "base/base_paths.h"
17 #include "base/bind.h" 19 #include "base/bind.h"
18 #include "base/files/file.h" 20 #include "base/files/file.h"
19 #include "base/files/file_util.h" 21 #include "base/files/file_util.h"
20 #include "base/files/scoped_temp_dir.h" 22 #include "base/files/scoped_temp_dir.h"
21 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
22 #include "base/memory/scoped_vector.h" 24 #include "base/memory/scoped_vector.h"
23 #include "base/process/launch.h" 25 #include "base/process/launch.h"
24 #include "base/test/scoped_path_override.h" 26 #include "base/test/scoped_path_override.h"
25 #include "base/threading/platform_thread.h" 27 #include "base/threading/platform_thread.h"
26 #include "base/threading/thread.h" 28 #include "base/threading/thread.h"
27 #include "chromecast/base/scoped_temp_file.h" 29 #include "chromecast/base/scoped_temp_file.h"
28 #include "chromecast/crash/linux/crash_testing_utils.h" 30 #include "chromecast/crash/linux/crash_testing_utils.h"
29 #include "chromecast/crash/linux/dump_info.h" 31 #include "chromecast/crash/linux/dump_info.h"
30 #include "chromecast/crash/linux/synchronized_minidump_manager.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 33
33 namespace chromecast { 34 namespace chromecast {
34 namespace { 35 namespace {
35 36
36 const char kLockfileName[] = "lockfile"; 37 const char kLockfileName[] = "lockfile";
37 const char kMetadataName[] = "metadata"; 38 const char kMetadataName[] = "metadata";
38 const char kMinidumpSubdir[] = "minidumps"; 39 const char kMinidumpSubdir[] = "minidumps";
39 40
40 // A trivial implementation of SynchronizedMinidumpManager, which does no work 41 // A trivial implementation of SynchronizedMinidumpManager, which does no work
41 // to the minidump and exposes its protected members for testing. This simply 42 // to the minidump and exposes its protected members for testing. This simply
42 // adds an entry to the lockfile. 43 // adds an entry to the lockfile.
43 class SynchronizedMinidumpManagerSimple : public SynchronizedMinidumpManager { 44 class SynchronizedMinidumpManagerSimple : public SynchronizedMinidumpManager {
44 public: 45 public:
45 SynchronizedMinidumpManagerSimple() 46 SynchronizedMinidumpManagerSimple()
46 : SynchronizedMinidumpManager(), 47 : SynchronizedMinidumpManager(),
47 work_done_(false), 48 work_done_(false),
48 add_entry_return_code_(-1), 49 add_entry_return_code_(-1),
49 lockfile_path_(dump_path_.Append(kLockfileName).value()) {} 50 lockfile_path_(dump_path_.Append(kLockfileName).value()) {}
50 ~SynchronizedMinidumpManagerSimple() override {} 51 ~SynchronizedMinidumpManagerSimple() override {}
51 52
52 void SetDumpInfoToWrite(scoped_ptr<DumpInfo> dump_info) { 53 void SetDumpInfoToWrite(scoped_ptr<DumpInfo> dump_info) {
53 dump_info_ = dump_info.Pass(); 54 dump_info_ = std::move(dump_info);
54 } 55 }
55 56
56 int DoWorkLocked() { return AcquireLockAndDoWork(); } 57 int DoWorkLocked() { return AcquireLockAndDoWork(); }
57 58
58 // SynchronizedMinidumpManager implementation: 59 // SynchronizedMinidumpManager implementation:
59 int DoWork() override { 60 int DoWork() override {
60 if (dump_info_) 61 if (dump_info_)
61 add_entry_return_code_ = AddEntryToLockFile(*dump_info_); 62 add_entry_return_code_ = AddEntryToLockFile(*dump_info_);
62 work_done_ = true; 63 work_done_ = true;
63 return 0; 64 return 0;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 const base::FilePath path = 545 const base::FilePath path =
545 base::FilePath(manager.dump_path()).Append("hello123"); 546 base::FilePath(manager.dump_path()).Append("hello123");
546 const char kFileContents[] = "foobar"; 547 const char kFileContents[] = "foobar";
547 ASSERT_EQ(static_cast<int>(sizeof(kFileContents)), 548 ASSERT_EQ(static_cast<int>(sizeof(kFileContents)),
548 WriteFile(path, kFileContents, sizeof(kFileContents))); 549 WriteFile(path, kFileContents, sizeof(kFileContents)));
549 550
550 ASSERT_TRUE(manager.HasDumps()); 551 ASSERT_TRUE(manager.HasDumps());
551 } 552 }
552 553
553 } // namespace chromecast 554 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/crash/linux/synchronized_minidump_manager.cc ('k') | chromecast/media/audio/cast_audio_output_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698