OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/diagnostics/recon_diagnostics.h" | 5 #include "chrome/browser/diagnostics/recon_diagnostics.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
15 #include "base/json/json_string_value_serializer.h" | 15 #include "base/json/json_string_value_serializer.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
22 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 #include "chrome/browser/diagnostics/diagnostics_test.h" | 25 #include "chrome/browser/diagnostics/diagnostics_test.h" |
25 #include "chrome/common/channel_info.h" | 26 #include "chrome/common/channel_info.h" |
26 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 RecordSuccess(current_version); | 324 RecordSuccess(current_version); |
324 return true; | 325 return true; |
325 } | 326 } |
326 | 327 |
327 private: | 328 private: |
328 DISALLOW_COPY_AND_ASSIGN(VersionTest); | 329 DISALLOW_COPY_AND_ASSIGN(VersionTest); |
329 }; | 330 }; |
330 | 331 |
331 } // namespace | 332 } // namespace |
332 | 333 |
333 DiagnosticsTest* MakeDiskSpaceTest() { return new DiskSpaceTest(); } | 334 std::unique_ptr<DiagnosticsTest> MakeDiskSpaceTest() { |
| 335 return base::MakeUnique<DiskSpaceTest>(); |
| 336 } |
334 | 337 |
335 DiagnosticsTest* MakeInstallTypeTest() { return new InstallTypeTest(); } | 338 std::unique_ptr<DiagnosticsTest> MakeInstallTypeTest() { |
| 339 return base::MakeUnique<InstallTypeTest>(); |
| 340 } |
336 | 341 |
337 DiagnosticsTest* MakeBookMarksTest() { | 342 std::unique_ptr<DiagnosticsTest> MakeBookMarksTest() { |
338 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); | 343 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); |
339 path = path.Append(bookmarks::kBookmarksFileName); | 344 path = path.Append(bookmarks::kBookmarksFileName); |
340 return new JSONTest(path, | 345 return base::MakeUnique<JSONTest>(path, DIAGNOSTICS_JSON_BOOKMARKS_TEST, |
341 DIAGNOSTICS_JSON_BOOKMARKS_TEST, | 346 2 * kOneMegabyte, JSONTest::NON_CRITICAL); |
342 2 * kOneMegabyte, | |
343 JSONTest::NON_CRITICAL); | |
344 } | 347 } |
345 | 348 |
346 DiagnosticsTest* MakeLocalStateTest() { | 349 std::unique_ptr<DiagnosticsTest> MakeLocalStateTest() { |
347 base::FilePath path; | 350 base::FilePath path; |
348 PathService::Get(chrome::DIR_USER_DATA, &path); | 351 PathService::Get(chrome::DIR_USER_DATA, &path); |
349 path = path.Append(chrome::kLocalStateFilename); | 352 path = path.Append(chrome::kLocalStateFilename); |
350 return new JSONTest(path, | 353 return base::MakeUnique<JSONTest>(path, DIAGNOSTICS_JSON_LOCAL_STATE_TEST, |
351 DIAGNOSTICS_JSON_LOCAL_STATE_TEST, | 354 50 * kOneKilobyte, JSONTest::CRITICAL); |
352 50 * kOneKilobyte, | |
353 JSONTest::CRITICAL); | |
354 } | 355 } |
355 | 356 |
356 DiagnosticsTest* MakePreferencesTest() { | 357 std::unique_ptr<DiagnosticsTest> MakePreferencesTest() { |
357 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); | 358 base::FilePath path = DiagnosticsTest::GetUserDefaultProfileDir(); |
358 path = path.Append(chrome::kPreferencesFilename); | 359 path = path.Append(chrome::kPreferencesFilename); |
359 return new JSONTest(path, | 360 return base::MakeUnique<JSONTest>(path, DIAGNOSTICS_JSON_PREFERENCES_TEST, |
360 DIAGNOSTICS_JSON_PREFERENCES_TEST, | 361 100 * kOneKilobyte, JSONTest::CRITICAL); |
361 100 * kOneKilobyte, | |
362 JSONTest::CRITICAL); | |
363 } | 362 } |
364 | 363 |
365 | 364 std::unique_ptr<DiagnosticsTest> MakeOperatingSystemTest() { |
366 DiagnosticsTest* MakeOperatingSystemTest() { return new OperatingSystemTest(); } | 365 return base::MakeUnique<OperatingSystemTest>(); |
367 | |
368 DiagnosticsTest* MakeDictonaryDirTest() { | |
369 return new PathTest(kPathsToTest[0]); | |
370 } | 366 } |
371 | 367 |
372 DiagnosticsTest* MakeLocalStateFileTest() { | 368 std::unique_ptr<DiagnosticsTest> MakeDictonaryDirTest() { |
373 return new PathTest(kPathsToTest[1]); | 369 return base::MakeUnique<PathTest>(kPathsToTest[0]); |
374 } | 370 } |
375 | 371 |
376 DiagnosticsTest* MakeResourcesFileTest() { | 372 std::unique_ptr<DiagnosticsTest> MakeLocalStateFileTest() { |
377 return new PathTest(kPathsToTest[2]); | 373 return base::MakeUnique<PathTest>(kPathsToTest[1]); |
378 } | 374 } |
379 | 375 |
380 DiagnosticsTest* MakeUserDirTest() { return new PathTest(kPathsToTest[3]); } | 376 std::unique_ptr<DiagnosticsTest> MakeResourcesFileTest() { |
| 377 return base::MakeUnique<PathTest>(kPathsToTest[2]); |
| 378 } |
381 | 379 |
382 DiagnosticsTest* MakeVersionTest() { return new VersionTest(); } | 380 std::unique_ptr<DiagnosticsTest> MakeUserDirTest() { |
| 381 return base::MakeUnique<PathTest>(kPathsToTest[3]); |
| 382 } |
| 383 |
| 384 std::unique_ptr<DiagnosticsTest> MakeVersionTest() { |
| 385 return base::MakeUnique<VersionTest>(); |
| 386 } |
383 | 387 |
384 } // namespace diagnostics | 388 } // namespace diagnostics |
OLD | NEW |