Add a callback argument to PersistentPrefStore::CommitPendingWrite().

The callback is invoked on the origin sequence when disk operations
are complete, even if they are unsuccessful. This will be used to
avoid relying on a named sequence token to wait for prefs to be
written to disk on end session.

[email protected]

Bug: 667892
Change-Id: I3b2678a7096f896f34590800e5843be5a186eb43
Reviewed-on: https://chromium-review.googlesource.com/517988
Commit-Queue: Francois Doray <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Jonathan Ross <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#478306}
diff --git a/components/prefs/persistent_pref_store_unittest.cc b/components/prefs/persistent_pref_store_unittest.cc
new file mode 100644
index 0000000..e2a65416
--- /dev/null
+++ b/components/prefs/persistent_pref_store_unittest.cc
@@ -0,0 +1,22 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/prefs/persistent_pref_store.h"
+
+#include "base/bind.h"
+#include "base/run_loop.h"
+#include "base/sequence_checker_impl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+void TestCommitPendingWriteWithCallback(PersistentPrefStore* store) {
+  base::RunLoop run_loop;
+  base::SequenceCheckerImpl sequence_checker;
+  store->CommitPendingWrite(base::BindOnce(
+      [](base::SequenceCheckerImpl* sequence_checker, base::RunLoop* run_loop) {
+        EXPECT_TRUE(sequence_checker->CalledOnValidSequence());
+        run_loop->Quit();
+      },
+      base::Unretained(&sequence_checker), base::Unretained(&run_loop)));
+  run_loop.Run();
+}