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

Unified Diff: services/authentication/accounts_db_manager.h

Issue 1466733002: Google OAuth Device Flow support for FNL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: services/authentication/accounts_db_manager.h
diff --git a/services/authentication/accounts_db_manager.h b/services/authentication/accounts_db_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..09a8cbc8575d3d0005a3cfb5f1cec19aa010c771
--- /dev/null
+++ b/services/authentication/accounts_db_manager.h
@@ -0,0 +1,75 @@
+// Copyright 2015 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.
+
+#ifndef SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_
+#define SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_
+
+#include <type_traits>
+
+#include "base/macros.h"
+#include "mojo/services/files/interfaces/files.mojom.h"
+#include "services/authentication/authentication_impl_db.mojom.h"
+
+namespace authentication {
+
+// Implementation of user account management service on systems like FNL. This
+// uses native mojo files service as the underlying mechanism to store user
+// credentials and supports operations such as to add a new user account, update
+// existing user credentials and fetching current credentials for a given user.
+class AccountsDbManager {
+ public:
+ AccountsDbManager();
+ explicit AccountsDbManager(const mojo::files::DirectoryPtr directory);
qsr 2016/02/16 14:17:06 Can you add some comment about those 2 constructor
ukode 2016/02/26 21:35:50 Got rid of one constructor.
+ ~AccountsDbManager();
+ // Updates or adds new auth credentials for a given user account.
+ void UpdateAccount(const mojo::String& username,
+ const mojo::String& account_data);
+ // Fetches auth credentials for a given user account.
+ mojo::String GetAccountDataForUser(const mojo::String& username);
+ // Fetches auth credentials for all user accounts.
+ mojo::String GetAllUserAccounts();
qsr 2016/02/16 14:17:06 What is the return value?
ukode 2016/02/26 21:35:50 Made this to return an array of usernames instead.
+ // Returns previously used account name for the given application or null if
+ // not found.
+ mojo::String GetAuthorizedUserForApp(mojo::String app_url);
+ // Updates the grants database for the given application and username.
+ void UpdateAuthorization(mojo::String app_url, mojo::String username);
+
+ private:
+ // Generates new contents of the accounts database during an update operation.
+ // Performs one of the two operations:
+ // 1. If the user already exists, updates the existing record in database.
+ // 2. If its a new user, adds a new record to the existing database content.
+ mojo::String GetUpdatedDbContents(const mojo::String& username,
+ const mojo::String& new_account_data,
+ bool user_exists);
+ // Populates contents with existing user credentials.
+ void Initialize();
+ // Reads from credentials file and populates in-memory contents cache.
+ void OnReadResponse(const mojo::files::Error error,
+ const mojo::Array<uint8_t> bytes_read);
+ // Parses response from credentials file write operation
+ void OnWriteResponse(const mojo::files::Error error,
+ const uint32_t num_bytes_written);
+ // Reads from auth file and populates in-memory grants cache.
+ void OnAuthFileReadResponse(const mojo::files::Error error,
+ const mojo::Array<uint8_t> bytes_read);
+ // Parses response from auth file write operation
+ void OnAuthFileWriteResponse(const mojo::files::Error error,
+ const uint32_t num_bytes_written);
+
+ // File pointer to the stored account credentials db file.
+ mojo::files::FilePtr creds_db_file_;
+ // File pointer to the list of authorized modules.
+ mojo::files::FilePtr auth_db_file_;
+ // Stores the cached account data for all users.
qsr 2016/02/16 14:17:06 What is the format of this string?
ukode 2016/02/26 21:35:50 removed this completely. Made it a credentials db
+ std::string contents_;
+ // In-memory store for list of authorized apps.
+ authentication::Db auth_grants;
qsr 2016/02/16 14:17:06 auth_grants_
ukode 2016/02/26 21:35:49 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(AccountsDbManager);
+};
+
+} // namespace authentication
+
+#endif // SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698