Home | History | Annotate | Download | only in browser
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "components/autofill/content/browser/autocheckout_statistic.h"
      6 
      7 #include "base/logging.h"
      8 #include "base/strings/string_number_conversions.h"
      9 #include "base/values.h"
     10 
     11 namespace autofill {
     12 
     13 namespace {
     14 
     15 std::string AutocheckoutStepToString(AutocheckoutStepType step) {
     16   switch(step) {
     17     case AUTOCHECKOUT_STEP_SHIPPING:
     18       return "AUTOCHECKOUT_STEP_SHIPPING";
     19     case AUTOCHECKOUT_STEP_DELIVERY:
     20       return "AUTOCHECKOUT_STEP_DELIVERY";
     21     case AUTOCHECKOUT_STEP_BILLING:
     22       return "AUTOCHECKOUT_STEP_BILLING";
     23     case AUTOCHECKOUT_STEP_PROXY_CARD:
     24       return "AUTOCHECKOUT_STEP_PROXY_CARD";
     25   }
     26   NOTREACHED();
     27   return "NOT_POSSIBLE";
     28 }
     29 
     30 }  // namespace
     31 
     32 AutocheckoutStatistic::AutocheckoutStatistic() : page_number(-1) {
     33 }
     34 
     35 AutocheckoutStatistic::~AutocheckoutStatistic() {
     36 }
     37 
     38 scoped_ptr<base::DictionaryValue> AutocheckoutStatistic::ToDictionary() const {
     39   scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
     40   std::string description = base::IntToString(page_number);
     41   for (size_t i = 0; i < steps.size(); ++i) {
     42     description = description + "_" + AutocheckoutStepToString(steps[i]);
     43   }
     44   dict->SetString("step_description", description);
     45   dict->SetInteger("time_taken", time_taken.InMilliseconds());
     46   DVLOG(1) << "Step : " << description
     47            << ", time_taken: " << time_taken.InMilliseconds();
     48   return dict.Pass();
     49 }
     50 
     51 }  // namespace autofill
     52 
     53