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

Side by Side Diff: Source/bindings/core/v8/Dictionary.cpp

Issue 340353006: [webcrypto] Replace KeyAlgorithm interfaces with an Object. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove const reference and make v8value a value Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "modules/speech/SpeechRecognitionResultList.h" 58 #include "modules/speech/SpeechRecognitionResultList.h"
59 #include "wtf/MathExtras.h" 59 #include "wtf/MathExtras.h"
60 60
61 namespace WebCore { 61 namespace WebCore {
62 62
63 Dictionary::Dictionary() 63 Dictionary::Dictionary()
64 : m_isolate(0) 64 : m_isolate(0)
65 { 65 {
66 } 66 }
67 67
68 Dictionary::Dictionary(v8::Isolate* isolate)
69 : m_options(v8::Object::New(isolate))
70 , m_isolate(isolate)
71 {
72 }
73
68 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat e) 74 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat e)
69 : m_options(options) 75 : m_options(options)
70 , m_isolate(isolate) 76 , m_isolate(isolate)
71 { 77 {
72 ASSERT(m_isolate); 78 ASSERT(m_isolate);
73 } 79 }
74 80
75 Dictionary::~Dictionary() 81 Dictionary::~Dictionary()
76 { 82 {
77 } 83 }
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 bool Dictionary::get(const String& key, RefPtr<Headers>& value) const 599 bool Dictionary::get(const String& key, RefPtr<Headers>& value) const
594 { 600 {
595 v8::Local<v8::Value> v8Value; 601 v8::Local<v8::Value> v8Value;
596 if (!getKey(key, v8Value)) 602 if (!getKey(key, v8Value))
597 return false; 603 return false;
598 604
599 value = V8Headers::toNativeWithTypeCheck(m_isolate, v8Value); 605 value = V8Headers::toNativeWithTypeCheck(m_isolate, v8Value);
600 return true; 606 return true;
601 } 607 }
602 608
609 bool Dictionary::set(const String& key, const v8::Handle<v8::Value>& value)
610 {
611 if (isUndefinedOrNull())
612 return false;
613 v8::Local<v8::Object> options = m_options->ToObject();
614 ASSERT(!options.IsEmpty());
615
616 return options->Set(v8String(m_isolate, key), value);
617 }
618
619 bool Dictionary::set(const String& key, const String& value)
620 {
621 return set(key, v8String(m_isolate, value));
622 }
623
624 bool Dictionary::set(const String& key, unsigned value)
625 {
626 return set(key, v8::Integer::NewFromUnsigned(m_isolate, value));
627 }
628
629 bool Dictionary::set(const String& key, const Dictionary& value)
630 {
631 return set(key, value.v8Value());
632 }
633
603 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona ry& value) const 634 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona ry& value) const
604 { 635 {
605 ConversionContextScope scope(context); 636 ConversionContextScope scope(context);
606 637
607 v8::Local<v8::Value> v8Value; 638 v8::Local<v8::Value> v8Value;
608 if (!getKey(key, v8Value)) 639 if (!getKey(key, v8Value))
609 return true; 640 return true;
610 641
611 if (v8Value->IsObject()) 642 if (v8Value->IsObject())
612 return get(key, value); 643 return get(key, value);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 799
769 return *this; 800 return *this;
770 } 801 }
771 802
772 void Dictionary::ConversionContext::throwTypeError(const String& detail) 803 void Dictionary::ConversionContext::throwTypeError(const String& detail)
773 { 804 {
774 exceptionState().throwTypeError(detail); 805 exceptionState().throwTypeError(detail);
775 } 806 }
776 807
777 } // namespace WebCore 808 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/Dictionary.h ('k') | Source/bindings/modules/v8/custom/V8CryptoKeyCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698